I want to make a gpa calculator in Go but I am stuck at how to take input from user and save in struct

I want to make a gpa calculator which first ask users to input their total credits for the semester. I achieved to do so. Then I want to take total subjects as input from user which I am able to do too. But now comes the real problem. I want to take input from user in the following form :- ```
“Maths”:“A”, “Physics”:“B”

Then to calculate gpa I want to do the following conversion from respective grade to score 
Like S = 10, A = 9, B = 8, C = 7 and use it to calculate their gpa with the eqation 

gpa = Total Score { Credit of subject * respective grade score} / Total credit 

So if a student has 2 subjects Math and Physics and credit for Math is 4 and he scores S and credit for Physics is 3 and he scores C then gpa will be :- 

gpa = 4(credit of Math) * 10(grade score for S) + 3(credit of Physics) * 7(grade score for C) / 7(Total Credits)

It’s not so clear, at least for me, your input format and also how the data are readed (from keybord or other form). However while your data didn’t come from an api for example is no reason I guess to read it in a coded form.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.