Question

In: Computer Science

I want to know how can I fix this program so it can work properly....can someone...

I want to know how can I fix this program so it can work properly....can someone run it and give me the fixed version but do not the entire program bear with this one please and thanks in advance!!!!!

import java.util.Scanner;

public class ifPractice
{
public static void main(String[] args)
{
Scanner KB = new Scanner(System.in);
{
double option;
double option02;
double stu_gradeTest01;
double stu_gradeTest02;
double stu_gradeTest03;
double final_grade;
{
System.out.println("Enter #1 to see what test to grade first, #2 for student's average, #3 " +
"to see what is the final grade for the student: ");
option = KB.nextDouble();

if(option == 1)
{
System.out.println("Let's see which exam to grade first....");
System.out.println("Now please choose #4 for first exam; #5 for second exam; #6 for final exam: ");
option02 = KB.nextDouble();
if(option02 == 4)
{
System.out.println("Grade exam one: ");
stu_gradeTest01 = KB.nextDouble();
System.out.println("The first exam: " + stu_gradeTest01);
}
else if(option02 == 5)
{
System.out.println("Grade exam two: ");
stu_gradeTest02 = KB.nextDouble();
System.out.println("The second exam: " + stu_gradeTest02);
}
else if(option02 == 6)
{
System.out.println("Grade exam three: ");
stu_gradeTest03 = KB.nextDouble();
System.out.println("The third exam: " + stu_gradeTest03);
}
else
System.out.println("Invalid entry.... program in lockdown until further notice....");
}
  


  
else if(option == 2)
{
System.out.println("These are all of the grades: ");
stu_gradeTest01 = KB.nextDouble();
stu_gradeTest02 = KB.nextDouble();
stu_gradeTest03 = KB.nextDouble();
final_grade = (stu_gradeTest01 + stu_gradeTest02 + stu_gradeTest03)/3.0;
System.out.println("The final grade is: " + final_grade);
}
else
System.out.println("Invalid entry...llocking system down....");
}


  

  
else if(option == 3)
{
System.out.println("The final grade the student got was: ");
final_grade = KB.nextDouble();
if(final_grade >= 90)
{
System.out.print("A");
final_grade = KB.nextDouble();
}
else if(final_grade >= 80 )
{
System.out.print("B");
final_grade = KB.nextDouble();
}
else if(final_grade >= 70)
{
System.out.print("C");
final_grade = KB.nextDouble();
}
else if(final_grade <= 65)
{
System.out.println("Your are failing");
final_grade = KB.nextDouble();
}
else if(final_grade >= 64)
{
System.out.println("F");
final_grade = KB.nextDouble();
}
else
{
System.out.println("Invalid enry.....lllocking down....");
}
}
else
System.out.println("Invalid entry");
}
}
}




  
  
  
  


  
  

Solutions

Expert Solution

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
_________________

// IfPractice.java

import java.util.Scanner;

public class IfPractice {
   public static void main(String[] args) {
       Scanner KB = new Scanner(System.in);
       {
           int option, option02;
           double stu_gradeTest01;
           double stu_gradeTest02;
           double stu_gradeTest03;
           double final_grade;

           System.out.println("Enter #1 to see what test to grade first, #2 for student's average, #3 "
                           + "to see what is the final grade for the student: ");
           option = KB.nextInt();

           if (option == 1) {
               System.out.println("Let's see which exam to grade first....");
               System.out.println("Now please choose #4 for first exam; #5 for second exam; #6 for final exam: ");
               option02 = KB.nextInt();
               if (option02 == 4) {
                   System.out.println("Grade exam one: ");
                   stu_gradeTest01 = KB.nextDouble();
                   System.out.println("The first exam: " + stu_gradeTest01);
               } else if (option02 == 5) {
                   System.out.println("Grade exam two: ");
                   stu_gradeTest02 = KB.nextDouble();
                   System.out.println("The second exam: " + stu_gradeTest02);
               } else if (option02 == 6) {
                   System.out.println("Grade exam three: ");
                   stu_gradeTest03 = KB.nextDouble();
                   System.out.println("The third exam: " + stu_gradeTest03);
               } else
                   System.out.println("Invalid entry.... program in lockdown until further notice....");
           }

           else if (option == 2) {
               System.out.println("These are all of the grades: ");
               stu_gradeTest01 = KB.nextDouble();
               stu_gradeTest02 = KB.nextDouble();
               stu_gradeTest03 = KB.nextDouble();
               final_grade = (stu_gradeTest01 + stu_gradeTest02 + stu_gradeTest03) / 3.0;
               System.out.println("The final grade is: " + final_grade);
           } else if (option == 3) {
               System.out.println("The final grade the student got was: ");
               final_grade = KB.nextDouble();
               if (final_grade >= 90) {
                   System.out.print("A");
                   final_grade = KB.nextDouble();
               } else if (final_grade >= 80) {
                   System.out.print("B");
                   final_grade = KB.nextDouble();
               } else if (final_grade >= 70) {
                   System.out.print("C");
                   final_grade = KB.nextDouble();
               } else if (final_grade <= 65) {
                   System.out.println("Your are failing");
                   final_grade = KB.nextDouble();
               } else if (final_grade >= 64) {
                   System.out.println("F");
                   final_grade = KB.nextDouble();
               } else {
                   System.out.println("Invalid enry.....lllocking down....");
               }
           } else
               System.out.println("Invalid entry");
       }
   }
}

______________________

Output#1:

Enter #1 to see what test to grade first, #2 for student's average, #3 to see what is the final grade for the student:
1
Let's see which exam to grade first....
Now please choose #4 for first exam; #5 for second exam; #6 for final exam:
4
Grade exam one:
45
The first exam: 45.0

________________________

Output#2:

Enter #1 to see what test to grade first, #2 for student's average, #3 to see what is the final grade for the student:
2
These are all of the grades:
56
78
89
The final grade is: 74.33333333333333

_______________Could you plz rate me well.Thank You


Related Solutions

I already have the code of this program, I just want to know how to fix...
I already have the code of this program, I just want to know how to fix the code to Implement the 5th function (System.nanotime() and System.currentTimeMillis() methods) What Code does: Introduction Searching is a fundamental operation of computer applications and can be performed using either the inefficient linear search algorithm with a time complexity of O (n) or by using the more efficient binary search algorithm with a time complexity of O (log n). Task Requirements In this lab, you...
I need to write a program and can't seem to make it run properly. Someone can...
I need to write a program and can't seem to make it run properly. Someone can help with the coding? It's with python Thanks! Here is the program: The rules of Shut the Box are as follows (abbreviated version): + You have two 5-sided die + You have 5 wooden blocks (labeled 1 through 5) + Each turn, you roll the dice and knock down the blocks corresponding to the number on each die + You have to knock down...
Python programming: can someone please fix my code to get it to work correctly? The program...
Python programming: can someone please fix my code to get it to work correctly? The program should print "car already started" if you try to start the car twice. And, should print "Car is already stopped" if you try to stop the car twice. Please add comments to explain why my code isn't working. Thanks! # Program goals: # To simulate a car game. Focus is to build the engine for this game. # When we run the program, it...
can someone fix the infinite loop, it's stupid question, I don't know why for add field...
can someone fix the infinite loop, it's stupid question, I don't know why for add field I get an infinite loop, but not for anything else #include<iostream> #include<string> #include<vector> using namespace std; int n, n2; int n3; int id; int m; char keno[50]; int x; struct entity {    string random_words{};    string title{};    char keno[50]{};    int y_tho{};    int random_numbers{};    int ID{};    int id{};    int I_hate_this{};    int x{};    int m{}; }; int...
Can someone tell me how to fix warning msg in my code of C ++? I...
Can someone tell me how to fix warning msg in my code of C ++? I got run-time error for this question please help me asap! Errors are: In function 'void bfs(int, int)': warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int j = 0; j < adj[pppp].size(); j++){ ^ In function 'int main()': warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d %d %d %d %d", &a, &q, &c, &N, &m); ^...
Can someone fix this code so that it can count comparison and exchange? import java.util.Arrays; class...
Can someone fix this code so that it can count comparison and exchange? import java.util.Arrays; class Main { static int comparisons; static int exchanges; // Recursive function to perform insertion sort on sub-array arr[i..n] public static void insertionSort(int[] arr, int i, int n) { int value = arr[i]; int j = i; // Find index j within the sorted subset arr[0..i-1] // where element arr[i] belongs while (j > 0 && arr[j - 1] > value) { arr[j] = arr[j...
Hello I have this error in the code, I do not know how to fix it....
Hello I have this error in the code, I do not know how to fix it. It is written in C++ using a Eclipse IDE Error: libc++abi.dylib: terminating with uncaught exception of type std::out_of_range: basic_string bus.h =========== #pragma once #include using namespace std; class Bus { private:    string BusId; // bus ID    string Manufacturer; // manufacturer of the bus    int BusCapacity; // bus capacity    int Mileage; // mileage of bus    char Status; // current status...
i want to know how to work out the problem 1.)Calculate the molarity of a solution...
i want to know how to work out the problem 1.)Calculate the molarity of a solution made by 20.2 g of sucrose, C12H22O11, in enough water tomake 650 mL of solution. The molar mass of sucrose is 342 g/mol.   2.) A solution was made by mixing 39.5 g of carbon disulfide (CS2, MW= 76.15g/mol), and 24.3 gof acetone (CH3OCH3, MW = 58.08g/mol). Assuming ideal solution behavior, calculate thetotal vapor pressure above the solution at 35 °C, given that the vapor...
I am currently pursuing my chemical engineering degree. I want to know, if i want work...
I am currently pursuing my chemical engineering degree. I want to know, if i want work in chemical industry in future, what are the most important Subject (specific topic) / concept which are important from industry perspective (list them). Also list some of most important book that every chemical engineer should have. Thankyou!!
Can someone please provide the answers so I can check my work? Baldwin Corporation Excerpts from...
Can someone please provide the answers so I can check my work? Baldwin Corporation Excerpts from the Statement of Financial Position for Baldwin Corporation as of September 30, Year 5, are presented below. Cash $   950,000 Accounts receivable (net) 1,675,000 Inventories   2,806,000 Total current assets $5,431,000 Accounts payable $1,004,000 Accrued liabilities      785,000 Total current liabilities $1,789,000 The Board of directors of Baldwin Corporation met on October 4, Year 5, and declared regular quarterly cash dividends amounting to $750,000 ($0.60 per share)....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT