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 1231- 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 1 error on a line.
1- Program prints the message Welcome to Java!
1 public class Welcome { Fix: _______________
2 public static void Main(String{} args){ Fix: _______________
3 System.out.println(Welcome to Java!); Fix: _______________
4} Fix: _______________
5) Fix: _______________
2- Program prints the message Another program that prints a lot.
1 public class Computer Science { Fix: _______________
2 public static void main(String[] args){ Fix: _______________
3 System.out.print(Another program); Fix: _______________
4 System.out.println(that prints a lot.) Fix: _______________
5} Fix: _______________
6} Fix: _______________
3- Program prints the two lines:
56+56=112
The sum is 112
1 public class Number3 Fix: _______________
2 public void main(String[] args){ Fix: _______________
3 System.out.println(56+56=112); Fix: _______________
4 System.out.println(The sum is +112) Fix: _______________
5) Fix: _______________
6} Fix: _______________
4- 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 256//With the correct value
1 public class Number 4{ Fix: _______________
2 public static main(String[] args){ Fix: _______________
3 int sideLength ==16; Fix: _______________
4 System.out.println(The area is (sideLength * sidelength))
Fix: _______________
5} Fix: _______________
6} Fix: _______________
5- Program creates an int variable called cost and prints out its value:
8 is the cost. //with the correct value of cost
1 public Class MysteryProgram { Fix: _______________
2 Public static void main(String[] args){ Fix: _______________
3 double cost =8; Fix: _______________
4 System.out.println(cost + is the cost.); Fix: _______________
5} Fix: _______________
6- Program creates an int variable called total and prints out its value:
Total: 42
1 public class 6thProgram { Fix: _______________
2 public static void main(String[] args){ Fix: _______________
3 int total; Fix: _______________
4 System.out.print(Total: + total) Fix: _______________
5} Fix: _______________
6} Fix: _______________

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!