Please also provide a README file of how the program works and what is suppose t
ID: 3625107 • Letter: P
Question
Please also provide a README file of how the program works and what is suppose to do. Also include a test plan for the program. ThanksObjective:
create and implement a simple class
properly use static variables, methods, and constants
use arrays to efficiently organize data
use the this keyword
Task:
Write a program that calculates a students grade for this class as follows:
Input a students grades into appropriate instance variable arrays
Contains static class variables for the weights of the various criteria (e.g., class participation is 10% or .10)
Computes the grade
Outputs the grade
Explanation / Answer
please rate - thanks
you weren't very specific, hope this is good
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 to exit):");
fname[i]=in.next();
}
System.out.printf(" Student Name Average ");
for(j=0;j<i;j++)
{name=fname[j]+" "+lname[j];
System.out.printf("%-50s%8.2f ",name,sum[j]);
}
}
public static double grades(String name,int kt,int percent)
{double sum=0,grade=0;
int i;
for(i=1;i<=kt;i++)
{ do
{if(kt==1)
System.out.print("Enter "+name+": ");
else
System.out.print("Enter "+name+" "+i+": ");
grade=in.nextDouble();
if(grade<0||grade>100)
System.out.println("must be between 0 and 100");
}while(grade<0||grade>100);
sum+=grade;
}
sum*=(percent/100.);
return sum;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.