Question

In: Computer Science

(java)Fix the code in this program. Fix lines, add lines… Comment each line that you fixed...

(java)Fix the code in this program. Fix lines, add lines…

Comment each line that you fixed … what you did to fix it.

import java.util.Scanner;
public static void main(String[] args)
{
// This program Converts grade Points into a Letter grade.
int gradePoints == 00; // Declare variable and assign initial value
System.out.printl("Enter Grade Points: ";
//Input gradePoints;
if ( gradePoints >= -42 )
{ System.out.println("Grade = A"); }
// if true, then ends here, if false drop to next line
else if ( gradePoints =< 80 ) { System.out.println("Grade = B"); }
//if true, then ends here, if false drop to next line
else if ( gradePoints >= 70 ) { System.out.println("Grade = C"); }
//if true, then ends here, if false drop to next line
else if ( gradePoints >= 60 ) { System.out.println("Grade = D"); }
// if true, then ends here, if false drop to next line
else { System.out.println("Grade = A"; } // done.
}

Solutions

Expert Solution

//TestCode.java
import java.util.Scanner;
public class TestCode {
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        // This program Converts grade Points into a Letter grade.
        int gradePoints; // Declare variable and assign initial value
        System.out.println("Enter Grade Points: ");
        gradePoints = scan.nextInt();
        //Input gradePoints;
        if ( gradePoints >= 90 ) {
            System.out.println("Grade = A");
        }
        // if true, then ends here, if false drop to next line
        else if ( gradePoints >= 80 ) {
            System.out.println("Grade = B");
        }
        //if true, then ends here, if false drop to next line
        else if ( gradePoints >= 70 ) { System.out.println("Grade = C"); }
        //if true, then ends here, if false drop to next line
        else if ( gradePoints >= 60 ) { System.out.println("Grade = D"); }
        // if true, then ends here, if false drop to next line
        else { System.out.println("Grade = A"); } // done.
    }
}


Related Solutions

Can you fix the code and comment the fix Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -39 at...
Can you fix the code and comment the fix Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -39 at CaesarCipher.encrypt(CaesarCipher.java:28) at CaesarCipher.main(CaesarCipher.java:52) public class CaesarCipher{     char[] encoder = new char[52];     char[] decoder = new char[52];      public CaesarCipher(int rotation)      {        for(int k=0 ; k < 26 ; k++)        {            encoder[k] = (char) ('A' + (k + rotation) % 26);            decoder[k] = (char) ('A' + (k - rotation + 26) % 26);        }        for(int j...
write a java program. 10-20 lines of code You are a landscaper, one of your first...
write a java program. 10-20 lines of code You are a landscaper, one of your first tasks is to determine the cost of landscaping a yard. You charge a flat fee of $40 to landscape a yard, and an extra $10 a bag for raking leaves. Not all yards you work on have leaves that need to be raked. Houses without any leaves will be discounted $5. Using your program, use the JOption Pane to ask the homeowner to enter...
I Have posted my Java code below. Fix the toString, add, and remove implementations so that...
I Have posted my Java code below. Fix the toString, add, and remove implementations so that the following test cases work. Note: I have removed all the unnecessary inherited List implementations. I have them to: throw new UnsupportedException(); For compilation, you could also add //TODO. Test (Main) List list = new SparseList<>(); list.add("0"); list.add("1"); list.add(4, "4"); will result in the following list of size 5: [0, 1, null, null, 4]. list.add(3, "Three"); will result in the following list of size...
This question is about java program. Please show the output and the detail code and comment...
This question is about java program. Please show the output and the detail code and comment of the each question and each Class and interface. And the output (the test mthod )must be all the true! Thank you! Question1 Create a class Animal with the following UML specification: +-----------------------+ | Animal | +-----------------------+ | - name: String | +-----------------------+ | + Animal(String name) | | + getName(): String | | + getLegs(): int | | + canFly(): boolean | |...
write code in java and comment. thanks. the program is about interface . Implement the basics...
write code in java and comment. thanks. the program is about interface . Implement the basics of Fitness and types of Fitness: Aerobic. Implement specific Fitness types such as Swimming, Cycling, Fitness Task: public interface Fitness (10pts) This will be used as a starting point for deriving any specific Fitness type. Every fitness exercise type has one or more muscle group it affects. Therefor a Fitness has the following abstarct method (Note that all methods in an interface are abstract...
Can you fix this code please. the removing methods id no doing anything. this is java...
Can you fix this code please. the removing methods id no doing anything. this is java code import java.util.NoSuchElementException; public class DoublyLinkedList<E> {    public int size;    public Node head;    public Node tail;             @Override    public boolean isEmpty() {               return size == 0;    }    @Override    public int getSize() {               return 0;    }    @Override    public void addAtFront(E element) {       ...
A Java program that deciphers each message by building the string. Each line of the text...
A Java program that deciphers each message by building the string. Each line of the text file contains either a word or a command followed by a forward slash and the requirements of the command. A Stack Implementation is needed as. As you read the data from the text file, you need to know if it is a new phrase or command. The commands are: i – an insert followed by the letters, numbers, or symbols that need to be...
In C++ Please comment in all-new lines of code, thank you DO NOT USE ANSWERS THAT...
In C++ Please comment in all-new lines of code, thank you DO NOT USE ANSWERS THAT ALREADY BEEN POSTED, please use code from the assignment Copy-paste will be reported Write a program to compare those two searching algorithms and also compare two sorting algorithms. You need to modify those codes in the book/slides to have some counters to count the number of comparisons and number of swaps. In the main function, you should have an ordered array of 120 integers...
Please add to this Python, Guess My Number Program. Add code to the program to make...
Please add to this Python, Guess My Number Program. Add code to the program to make it ask the user for his/her name and then greet that user by their name. Please add code comments throughout the rest of the program If possible or where you add in the code to make it ask the name and greet them before the program begins. import random def menu(): print("\n\n1. You guess the number\n2. You type a number and see if the...
Can you please add comments to this code? JAVA Code: import java.util.ArrayList; public class Catalog {...
Can you please add comments to this code? JAVA Code: import java.util.ArrayList; public class Catalog { String catalog_name; ArrayList<Item> list; Catalog(String cs_Gift_Catalog) { list=new ArrayList<>(); catalog_name=cs_Gift_Catalog; } String getName() { int size() { return list.size(); } Item get(int i) { return list.get(i); } void add(Item item) { list.add(item); } } Thanks!
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT