Question

In: Computer Science

Write a Java program that will ask the user for his/her mark (numerical integer mark) and...

Write a Java program that will ask the user for his/her mark (numerical integer mark) and then convert this numerical mark into letter grades. The following is a guideline to the grading scale used. The numeric range within parenthesis maps to the preceding letter grade. If the user gave you a number greater than 100 or less than 0, you should print a message that the input is invalid. In this code, DO NOT USE && OPERATOR. You should use if-else.

Grades Mapping

A+ (90 to100)

A (80 to 89)

B+ (75 to 79)

B (70 to 74)                                                                                                                                           

C+ (65 to 69)       

C (60 to 64)     

D+ (55 to 59)    

D (50 to 54)

E (40 to 49)        

F (0 to 39)

Solutions

Expert Solution

Required program in java -->

import java.util.*;
public class Main
{
   public static void main(String[] args) {
   Scanner sc= new Scanner(System.in);
   System.out.println("Enter marks"); //ask user for input
   int marks = sc.nextInt(); //read input from user
   if((marks+10)>=100){ //if marks+10 is smaller than 100
   if(marks<=100){ //if marks is less than or equal to 100
   System.out.println("A+"); //then print A+
   }
   else{ //else
   System.out.println("Invalid Input"); //print invalid
   }
   }
   else if((marks+10)>=90){
   System.out.println("A");
   }
   else if((marks+5)>=80){
   System.out.println("B+");
   }
   else if((marks+5)>=75){
   System.out.println("B");
   }
   else if((marks+5)>=70){
   System.out.println("C+");
   }
   else if((marks+5)>=65){
   System.out.println("C");
   }
   else if((marks+5)>=60){
   System.out.println("D+");
   }
   else if((marks+5)>=55){
   System.out.println("D");
   }
   else if((marks+10)>=50){
   System.out.println("E");
   }
   else if((marks+40)>=40){
   System.out.println("F");
   }
   }
}

we cannot use && operators here, so we have used + operator to check whether the given input falls in the criteria. And according to marks, we have provided the resultant grade.

so, if user enters 55

o/p -> D+


Related Solutions

Write a Java program that will ask the user for his/her salary (numerical integer salary) and...
Write a Java program that will ask the user for his/her salary (numerical integer salary) and then convert this numerical salary into income class. The following is a guideline to the income class used. The numeric range within parenthesis maps to the preceding class. If the user gave you a number greater than 700,000 or less than 10,000, you should print a message that the input is invalid. In this code, DO NOT USE && OPERATOR. You should use if-else....
Write a program to find the prime numbers IN JAVA Ask user to input the integer...
Write a program to find the prime numbers IN JAVA Ask user to input the integer number test the number whether it is a prime number or not Then, print “true” or “false” depending on whether the number is prime or isn’t. Hint: number is prime when is has exactly 2 factors: one and itself. By this definition, number 1 is a special case and is NOT a prime. Use idea of user input, cumulative sum, and loop to solve...
Write a program that does the following. It will ask the user to enter an integer...
Write a program that does the following. It will ask the user to enter an integer larger than 1, and the if entered integer is not larger than 1, it keeps prompting the user. After the user enters a valid integer, the program prints all the prime factors of the integer (including the repeated factors). For example, if the entered integer is 24, the program prints: 2 2 2 3 Run your program with the test cases where the entered...
c++ Write a program that will ask the user for three pairs of integer values. The...
c++ Write a program that will ask the user for three pairs of integer values. The program will then display whether the first number of the pair is multiple of the second. The actual work of making the determination will be performed by a function called IsMultiple that takes two integer arguments (say, x and y). The function will return a Boolean result of whether x is a multiple of y.
Write a Java program that asks the user to enter an integer that is used to...
Write a Java program that asks the user to enter an integer that is used to set a limit that will generate the following four patterns of multiples of five using nested loops •Ascending multiples of five with ascending length triangle •Ascending multiples of five with descending length (inverted) triangle •Descending multiples of five with ascending length triangle •Descending multiples of five with descending length (inverted) triangle Use error checking to keep asking the user for a positive number until...
Write a mips assembly code program that ask the user to enter an integer value, and...
Write a mips assembly code program that ask the user to enter an integer value, and then print the result of doubling that number.
(8 marks) Write a program to ask user to enter an integer that represents the number...
Write a program to ask user to enter an integer that represents the number of elements, then generate an ArrayList containing elements which are all random integers in range [75, 144] , and finally display index and value of each element. REQUIREMENTS The user input is always correct (input verification is not required). Your code must use ArrayList. Your program must use only printf(…) statements to adjust the alignment of your output. Your code must display the index in descending...
write a program i java that ask the user to enter salary, user ID and username...
write a program i java that ask the user to enter salary, user ID and username and out put them
Write a Java program that prompts the user to enter a list of integer values and...
Write a Java program that prompts the user to enter a list of integer values and displays whether the list is sorted in increasing order or not. Here is a sample run. Note that the first number in the input indicates the number of the elements in the list. <Output> Enter list: 8 101516619111 The list is not sorted <End Output <Output> Enter list: 10 11344579 11 21 The list is already sorted <End Output Create a complete class for...
Write java program that will ask for the user for 2 input lines and print out...
Write java program that will ask for the user for 2 input lines and print out all words that occur 1 or more times on both lines (case sensitive). Write this without arrays and method. Here is a sample run: <Output> Enter two lines to process. The quick brown fox jumps over a lazy dog The fox hound outruns the lazy dog The words that occur on both lines are: The fox lazy dog
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT