Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Guvenli ?httos://mcodle tedu.edu trip qinfile.php6g846/med resource, content 6/L

ID: 3706106 • Letter: G

Question

Guvenli ?httos://mcodle tedu.edu trip qinfile.php6g846/med resource, content 6/Lab06 Version!-3.pdf Witepogram to caloulate an average semester erde o sudent. The input to the program will include two parts, a name anda st t assignment scones with weights. The name space shouldn't contain any numeric value If the name length is , o the name space contains numerical valuc then an erar message valid Input) shouid be displayed, and the program should stop immediately. The assignment scores wil te entereda st of numbars. For each assianment, there will be two umbers, a sore Tollowed by s weight, The soores must be between 0 and 100. The weights mus also he between o and 1.0, and the weights must add up to 1.0.The sentinel value-1 will indcate the end of the list. User will enter the score and weight accordingly until -1 entered. If any number is out of the range specified above, unfthe weights du rot ddd to 1.0, ?" erru' message Invalid Input should he displayed, and the program should stop immediately The semester erade shouid be calkulated by multiplyie each score by its crespondire weight dlvided by 100) to produce a weighted score, and then adding the weighted scones to produce a total score. For example, these numbers describe four assignments 0.10 90 0.25 75 0.25 90 0.40-1 The first assignment has a score ot 85 and a weight or o 10, the second ascone or 90 and awigt at 0.2s, etc. The total score is (86" D. 10 90 * 0.25 + 75·0.25 + 90 . 0.401 85.9 The final result should be rounded to one decimalplae (0.1) Semester letter grades are iven by this tabe 3:800 tolal?90.0 F: total 60,0 NOTE: To configure the Scanner to accept decimal points, it's lccale must be changed using the setlocae(l method. The second line should be added after first line Scanner keyboard new ScannerlSystem.inl keyboard.setLocale Locale.US): use decimal points Enter the stuent 8 name: Mary B Snith Enter the sco es: 80 0,10 90 0,25 55 0,25 60 0,40 1 Neiqited total fo Nary Smith: 68.33, Grade: D Enter the tudent's rianie : Windowsu ara

Explanation / Answer

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package cheggquestions;
import java.text.DecimalFormat;
import java.util.*;
/**
*
* @author Prashant Tomer
*/
public class Grades {
  
public static void main(String aa[])
{
char grade;
float total=0.0f;
float marks[]=new float[8];
int decimalpoint;
Scanner sc=new Scanner(System.in);
System.out.println("Enter name of student:");
  
String name=sc.next();
  
  

  
System.out.println("Enter the scores:");
for(int i=0;i<marks.length;i++)
{
marks[i]=sc.nextFloat();
  
}
  
decimalpoint=sc.nextInt();
  
for(int i=0;i<marks.length-1;i=i+2)
{
total=total+(marks[i]*marks[i+1]);
  
}
  
if(total>90.0)
{
grade='A';
}
else if(total>=80.0 & total<90.0)
{
grade='B';
  
}
else if(total>=70.0 & total<80.0)
{
grade='C';
  
}
  
else if (total>=60.0 & total<70.0)
{
grade='D';
}
else
{
grade='E';
}
  

System.out.println(name+"Your Weigted is");
System.out.printf("%.1f",total);
System.out.print(",Grade:"+grade);
  
}
  
  
  
}

O/P:

Enter name of student:
Prashant
Enter the scores:
80 .10 90 .25 55 .25 60 .40 1
PrashantYour Weigted is
68.3,Grade:D