Question: CPS 1 2 3 1 - Basic Java FInd the errors in each of the following programs. Identify the error and make the correction to
CPS Basic Java
FInd the errors in each of the following programs. Identify the error and make the correction to make
the program run. Not every line has an error, and there may be more than error on a line.
Program prints the message Welcome to Java!
public class Welcome Fix:
public static void MainString args Fix:
System.out.printlnWelcome to Java!; Fix:
Fix:
Fix:
Program prints the message Another program that prints a lot.
public class Computer Science Fix:
public static void mainString args Fix:
System.out.printAnother program; Fix:
System.out.printlnthat prints a lot. Fix:
Fix:
Fix:
Program prints the two lines:
The sum is
public class Number Fix:
public void mainString args Fix:
System.out.println; Fix:
System.out.printlnThe sum is Fix:
Fix:
Fix:
Program creates an int variable for the length of the side of a square, then does the math to find the
area and prints the message:
The area is With the correct value
public class Number Fix:
public static mainString args Fix:
int sideLength ; Fix:
System.out.printlnThe area is sideLength sidelength
Fix:
Fix:
Fix:
Program creates an int variable called cost and prints out its value:
is the cost. with the correct value of cost
public Class MysteryProgram Fix:
Public static void mainString args Fix:
double cost ; Fix:
System.out.printlncost is the cost.; Fix:
Fix:
Program creates an int variable called total and prints out its value:
Total:
public class thProgram Fix:
public static void mainString args Fix:
int total; Fix:
System.out.printTotal: total Fix:
Fix:
Fix:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
