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...
Java. If possible please put explanations for each line of code. Write a test program that...
Java. If possible please put explanations for each line of code. Write a test program that prompts the user to enter a series of integers and displays whether the series contains runLength consecutive same-valued elements. Your program’s main() must prompt the user to enter the input size - i.e., the number of values in the series, the number of consecutive same-valued elements to match, and the sequence of integer values to check. The return value indicates whether at least one...
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...
3.) Analyze the Java Program LinkRotator RUN the code and add the screenshot of the window...
3.) Analyze the Java Program LinkRotator RUN the code and add the screenshot of the window and output. Describe what code change you would make if you wanted each link to be displayed for 2.5 seconds. _______________________________________________________________ Below is the "LinkRotator" java program: 1: package com.java24hours; 2: 3: import java.awt.*; 4: import java.awt.event.*; 5: import java.io.*; 6: import javax.swing.*; 7: import java.net.*; 8:    9: public class LinkRotator extends JFrame 10: implements Runnable, ActionListener { 11: 12: String[] pageTitle =...
Comment the code explaining what each line is doing. The first line has been done for...
Comment the code explaining what each line is doing. The first line has been done for you. x=[0 0 -1 2 3 -2 0 1 0 0]; %input discrete-time signal x dtx= -2:7; y=[1 -1 2 4]; dty=8:11; z=conv(x,y); dtz=6:18; subplot(1,3,1), stem(dtx,x) subplot(1,3,2), stem(dty,y) subplot(1,3,3), stem(dtz,z)
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) {       ...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT