Please see my first 2 questions to do this question 1. Using a similar approach
ID: 3541290 • Letter: P
Question
Please see my first 2 questions to do this question
1. Using a similar approach as the example provided in section 2.3 add comments to your pseudocode
2. Determine a full set of test data that will adequately test your program. Show the test input data (Test data) along with the expected output from your program. Your test data needs to presented in the form of a table as was shown in Assignment 1. Be sure that you provide expected output for each test case. Also be sure that you have sufficient data to fully test your program.
Explanation / Answer
Test Data 1
User Input : 97.23
Expected Output
A
Test Data 2
User Input : 80
Expected Output
B
Test Data 3
User Input : -2
Expected Output
Invalid input from the user
Test Data 4
User Input : 45
Expected Output
F
JAVA CODE
import java.util.Scanner;
public class CarPriceCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter a score");
double score = scanner.nextDouble();
char grade =' ';
if (score > 100 || score < 0){
System.out.println("Invalid input from the user");
System.exit(1);
}
else {
grade = assignGrade(score);
}
System.out.println("Grade assigned is :"+grade);
}
public static char assignGrade(double score ){
char grade=' ';
if (score >=90 && score <= 100 ){
grade = 'A';
}
else if (score >=80 && score <90){
grade = 'B';
}
else if (score >=70 && score <80){
grade = 'C';
}
else if (score >=60 && score <70){
grade = 'D';
}
else {
grade = 'F';
}
return grade;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.