Check errors and revise/update this java code below and update with OOp class; at least make...

60.1K

Verified Solution

Question

Programming

  1. Check errors and revise/update this java code below andupdate with OOp class; at least make two classes, use java library,validate user input, format and create UML/Pseudocode and flowchartfor the code.

import java.util.Scanner;

public class TestScore

{

   public static void main(String[] args) {

       String firstName;

       String lastName;

       int numTest;

       int i;

       int score;

       double totalScore;

       double avgScore;

       String grade;

       Scanner input = newScanner(System.in);

       System.out.println(\"EnterFirst Name\");

       firstName =input.nextLine();

       System.out.println(\"EnterLast Name\");

       lastName =input.nextLine();

       System.out.println(\"Howmany test score do you want to enter: \");

       numTest =input.nextInt();

       while(!input.hasNextDouble())

       {

           numTest= input.nextInt();

           System.out.println(\"Invalidentry, try again\");

       }

       totalScore = 0;

       for (i = 0; i <=numTest - 1; i++) {

           score= input.nextInt();

           totalScore= totalScore + score;

       }

       avgScore = totalScore/ numTest;

       if (avgScore >= 90){

           grade= \"A\";

       } else {

           if(avgScore >= 80) {

               grade= \"B\";

           }else {

               if(avgScore >= 75) {

                   grade= \"C\";

               }else {

                   if(avgScore >= 50) {

                       grade= \"D\";

                   }else {

                       grade= \"F\";

                   }

               }

           }

       }

       System.out.println(firstName+ \" \" + lastName + \" \" + avgScore + \" \" + grade);

   }

}

Answer & Explanation Solved by verified expert
3.7 Ratings (669 Votes)
Updated codewith OOPs classes is given belowThere are 2classes First is PersonalInfo and Second is Marks class And thenwe have a class Main that has main methodimport javautilScannerclass PersonalInfoString firstNameString lastNamepublic    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students