Homework 1 - Fix Sergio's buggy code
Due 1/14
Compile, run, and debug the java
programs given below. For each problem
provide a brief description of what is wrong, as well as a printout of the
debugged code and a printout of a successful run to verify that everything has
been tested.
The following programs will not
compile, why? Show the correct code and output.
//Problem 1
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public static void main(String[] args)
{
public class columbus
{
System.out.println(“In 1492 Columbus sailed the ocean blue”);
{
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Problem 2
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public class GreatFun
{
System.out.println(“Programming is
fun”);
{
public static void main(String[] args)
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
What is the output of this program if any. If it doesn’t have an output explain
why and fixe it.
//Problem 3
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public class Coffee
{
public static void main(String[] args)
{
System.out.print(“These are our
top sellers:\n”);
System.out.print(“computer games.
\nCoffee\n”);
System.out.print(“Aspirin\n”);
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Problem 4
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public static void main (String[] args)
}
public class Wolfgang
{
System.out.print(“the works of
Wolfgang \ninclude”);
System.out.print(“The follows…);
System.out.print(“\nThe Tourist March “);
System.out.print(“and symphony No. 40”);
System.out.print(“in G minor\n.”);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Complete or correct the following program
skeleton so it displays the message:
Hello world
I love to
Program in
Java
//Problem 5
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////public
class HelloWorld
{
public static void main (String[]
args)
}
// insert the code here to complete
the program
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////