Question
Please help me get the program to read my user inputs for HW, MdTerm, and Finl. I cannot figure out how to get the variables
Please help me get the program to read my user inputs for HW, MdTerm, and Finl. I cannot figure out how to get the variables to be read within the while loop so that I can solve for the total grade or figure out how to get the user to input valid options/specific options and have them retry if their input is invalid. I will rate for correct answers and good help!!!
import java.util.Scanner;
public class Lab3 {
public static void main(String[] args) { // This scanner is prepared for you to get inputs Scanner scan = new Scanner(System.in); //set up the i value System.out.println("Enter 1 to input the homework, 2 to input the midterm grade, and 2 to input the final grade"); int i = scan.nextInt();
//Start the while loop while (i > -1 || i
//Nest if loops to input homework, midtrm, and finl grades:
//HW Inputs if (i == 0) { System.out.println("Enter the homework grade/points: "); int HW = scan.nextInt();
final double homework = HW;
//Catch invalid inputs if (HW >= 0 || HW
}
//Midtrm Inputs if (i == 1) { System.out.println("Enter the MidTrm grade/points: "); int MidTrm = scan.nextInt(); //Catch invalid inputs if (MidTrm >= 0 || MidTrm
else if (i ==2) { System.out.println("Enter the Finl grade/points: "); int Finl = scan.nextInt();
//Catch invalid inputs if (Finl >= 0 || Finl
}
double Total = homework * 0.25 + MidTrm*0.25 + Finl*0.5;
double weighted_total = (Total);
if (weighted_total > 50) { System.out.println("The student PASSED the class."); } else { System.out.println("The student FAILED the class."); }
scan.close();
} } }
Lab Topics . Using the Scanner Class with input validation . Getting familiar with the basic tow control in Java Input validation Problem Description: Final Weighted Total Calculator Your task is to design a program which takes user inputsas homework grade, midiem cum grade, and final exam grade. Then use the following formula to cakulate the weighted to Totalrighi - ( x200x56) + (x 0.29 + (Homework * 0,25) If the weighted total is greater er equal to Sop50), show "Student PASSED de class". Otherwise, show "Shadow FAILED she less Your program has to validate the input values. A homework grade and midiem cum score should be in the range 0.100. The final cun grade should be in the range 10, 2003. If an input is invalid, you have to let the nereyinmeyil it is a valid input Note: You must hap Sample Output Samp Ben Che merred the cak Enter your HOMEWORK grade: 200 Enter your MIDTERM EXAM grader 76 Enter your FINAL EXAM grade: 10 [INO) Student's weighted Total is 64.00 [INFO) Student PASSED the classStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started