Mar-05-2020, 01:54 AM
Hey guys! I'm currently taking my first programming class (hopefully my last lol) and have little to no prior experience with programming. I'm at a standstill in my first "major" project, but have 90% of the code written. I appreciate everybody who takes their time to read this.
I think it's relevant to show you guys my teachers specifications for this project:
Your fellow students need help. This is their first year in college and they need to determine how many hours they need to study to get good grades.
Study Hours Per Week Per Class Grade
15 = A
12 = B
9 = C
6 = D
0 = F
1. The user enters their full name and the number of credits they are taking.
2. The user will then enter the grade they want assuming the same grade for all classes.
3. The program displays for each student: student’s name, number of credits, total number of weekly study hours, and grade they should expect to receive. In the following format –
Name: FirstName LastName
Credits: 12
Study Hours: 60
Grade: A
## I'm stuck on number 4
4. At the end of the program, the program displays the total number of students who used the program, the average credits taken, and the average study hours. In the following format –
Total Students: 3
Average Credits: 9
Average Study Hours: 20
So leading up to this project I did miss a couple classes when we talked about for loops, I assume I must use an accumulator to get the total number of students. Getting the average credits and average study hours, I assume I would use a for loop. I'm not having a syntax issue I'm having a logical issue right now because this project is jumbled I cant see a clear solution. My code did run perfectly until I decided to code in step 4, then I realized I don't know how to.
Here's what I have coded so far:
Of course I've tried to refer to my textbook for help and looked up examples that I could maybe adapt to my situation, but I just can't think clearly about this anymore, I've been working on this for over a week, if anybody could help point me in the right direction or explain what I have to do to collect the total number of users (I think I coded that correctly), and calculate the average credit hours and average study hours.
-Much appreciated,
Andrew
I think it's relevant to show you guys my teachers specifications for this project:
Your fellow students need help. This is their first year in college and they need to determine how many hours they need to study to get good grades.
Study Hours Per Week Per Class Grade
15 = A
12 = B
9 = C
6 = D
0 = F
1. The user enters their full name and the number of credits they are taking.
2. The user will then enter the grade they want assuming the same grade for all classes.
3. The program displays for each student: student’s name, number of credits, total number of weekly study hours, and grade they should expect to receive. In the following format –
Name: FirstName LastName
Credits: 12
Study Hours: 60
Grade: A
## I'm stuck on number 4
4. At the end of the program, the program displays the total number of students who used the program, the average credits taken, and the average study hours. In the following format –
Total Students: 3
Average Credits: 9
Average Study Hours: 20
So leading up to this project I did miss a couple classes when we talked about for loops, I assume I must use an accumulator to get the total number of students. Getting the average credits and average study hours, I assume I would use a for loop. I'm not having a syntax issue I'm having a logical issue right now because this project is jumbled I cant see a clear solution. My code did run perfectly until I decided to code in step 4, then I realized I don't know how to.
Here's what I have coded so far:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# This program will help my fellow students to determine how # many hours they need to study to get good grades. # Study and Grade Calculator Version 1.00 updated Feb 12, 2020 # Initialize variables runAgain = 'Y' totalStudents = 0 averageCredits = 0 averageStudy = 0 ##### Welcome user to the Study and Grade Calculator program. print ( "Welcome to the Study and Grade Calculator\n" + "By Andrew Rodriguez \n" + "Version 1.00 updated Feb 12, 2020\n\n" ) # Loop continues as long as user enter Y or y while runAgain = = 'Y' or runAgain = = 'y' or runAgain = = 'yes' or runAgain = = 'Yes' : ##### Collect user data: Name, Credits, and Grade desired. # Ask user's name and validate data userName = input ( 'Please enter your full name (First, Last): \n' ) while userName = = "" or userName.isdigit(): print ( 'Invalid name' ) userName = input ( 'Please enter your full name (First, Last): \n' ) totalStudents = 1 + totalStudents # Ask user for number of credits they are taking and validate data creditAmount = input ( "Please enter how many credits you're taking: \n" ) while not creditAmount.isdigit() or int (creditAmount) < 0 or int (creditAmount) > = 20 : print ( 'Invalid amount of credits' ) creditAmount = input ( "Please enter how many credits you're taking: \n" ) # Accumulator userCredits = creditAmount + userCredits # Ask user to enter the grade they want and validate data desiredGrade = input ( 'Please enter your desired letter grade: \n' ) while desiredGrade = = "" or desiredGrade.isdigit(): print ( 'Invalid grade' ) desiredGrade = input ( 'Please enter a valid desired letter grade: \n' ) # Desired grade decision structure if desiredGrade = = "A" or desiredGrade = = "a" : studyHours = 15 elif desiredGrade = = "B" or desiredGrade = = "b" : studyHours = 12 elif desiredGrade = = "C" or desiredGrade = = "c" : studyHours = 9 elif desiredGrade = = "D" or desiredGrade = = "d" : studyHours = 6 elif desiredGrade = = "F" or desiredGrade = = "f" : studyHours = 0 else : print ( 'Invalid Grade' ) studyHours = 'Invalid Grade' #Accumulator averageStudy = averageStudy + studyHours ##### Display results print ( "\nName: " , userName, "\nCredits: " , creditAmount, "\nStudy Hours: " , studyHours, "\nGrade: " , desiredGrade) for averageCredits in range (userCredits): for averageStudy in range (userStudy): # Ask the user if they want to run this program again runAgain = input ( 'Would you like to run this program again? (Y/N)' ) # Thank the user for using the application print ( 'Thank you for caring about your grades!' ) |
-Much appreciated,
Andrew