Question: R 2 . 1 1 Find at least five compile - time errors in the following program. public class HasErrors { public static void main

R2.11Find at least five compile-time errors in the following program.
public class HasErrors
{
public static void main();
{
System.out.print(Please enter two numbers:)
x = in.readDouble;
y = in.readDouble;
System.out.printline("The sum is "+ x + y);
}
}
R2.12Find three run-time errors in the following program.
public class HasErrors
{
public static void main(String[] args)
{
int x =0;
int y =0;
Scanner in = new Scanner("System.in");
System.out.print("Please enter an integer:");
x = in.readInt();
System.out.print("Please enter another integer: ");
x = in.readInt();
System.out.println("The sum is "+ x + y);
}
}
R2.13Consider the following code segment.
double purchase =19.93;
double payment =20.00;
double change = payment - purchase;
System.out.println(change);
The code segment prints the change as 0.07000000000000028. Explain why. Give a recommendation to improve the code so that users will not be confused.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!