Write a program that gets the names of and the grades that anunspecified number
ID: 3614627 • Letter: W
Question
Write a program that gets the names of and the grades that anunspecified number of students received on their assignments andexams, then calculates and displays each student’saverage.
The average is a weighted average calculated as specifiedbelow:
Assignments – 20%
Exam #1 – 25%
Exam #2 – 25%
Final exam – 30%
There will be six assignments. Each assignment/exam gradeentered should be a real number (may include a decimal point and afractional part) in the range 0 through 100 inclusive.
The user must be asked to enter the data in the followingorder: name of student, six assignment grades, exam #1 andexam #2, and then the final exam grade.
You may not ask the user for the number of studentswhose data is to be entered.
Use the standard input/output devices. Do not usedialog boxes in this program
Make sure you validate the grades entered. You do not haveto do any validation on the names entered.
Display one student’s name and average per line on thecomputer screen. Display the names left-justified under theheading Student Name in a column that is fifty characterswide. Display the averages with exactly one digit to theright of the decimal point, right-justified in a column that iseight characters wide under the heading Average. There should be one tab between the columns.
Explanation / Answer
please rate - thanks import java.util.*; public class weighted_average {static Scanner in=new Scanner(System.in); public static void main(String[] args) {String lname[]=new String[20]; String fname[]=new String[20]; String name; double sum[]=new double[20]; int i=0,j; System.out.print("Enter first name(Done to exit):"); fname[i]=in.next(); while (fname[i].compareToIgnoreCase("Done" )!=0) {System.out.print("Enter last name:"); lname[i]=in.next(); sum[i]+=grades("Assignment",6,20); sum[i]+=grades("Exam#1",1,25); sum[i]+=grades("Exam#2",1,25); sum[i]+=grades("Final Exam",1,30); i++; System.out.print(" Enter first name(Done toexit):"); fname[i]=in.next(); } System.out.printf(" StudentName Average "); for(j=0;jRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.