The following
public static void main(String[] args)
}
// A crazy mixed up program
public class Columbus
{
System.out.println(“In 1492 Columbus sailed the ocean blue.”};
{
}
When the lines are properly arranged, the program should display the following on the screen:
In 1492 Columbus sailed the ocean blue.
Rearrange the lines in the correct order. Test the program by entering it on the computer, compiling it, and running it.
Trending nowThis is a popular solution!
Learn your wayIncludes step-by-step video
Chapter 2 Solutions
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Additional Engineering Textbook Solutions
Starting Out with Java: Early Objects (6th Edition)
C How to Program (8th Edition)
Java How To Program (Early Objects)
Starting Out With Visual Basic (7th Edition)
Programming in C
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
- **JAVA DEBUGGING** The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. public classDebugSeven3 { public static void main(String[] args) { String quote = "Honesty is the first chapter in the book of wisdom. - Thomas Jefferson"; System.out.println("index.of('f') is: " + quoteindexOf('f')); System.out.println("index.of('x') is: " + quoteindexOf('x')); System.out.println("char.At(5) is: " + quote.charAt(50)); System.out.println("endsWith(\"daughter\") is: " + quote.endsWith("daughter")); System.out.println("endsWith(\"son\") is: " + quote.endsWith("son")); System.out.println("replace('e', '*') is: ", quote.replace('e', '*')); } }arrow_forwardJava: The class will contain the following static methods: reverseS – A method that displays a string reversely on the console using the following signature: public static void reverseS(String s) printSub1 – print all substrings of a string (duplicated substrings are allowed, but loops are not allowed). The method signature: public static void printSub1(String s) printSub2 – print all substrings of a string (duplicated substrings are not allowed, but loops are allowed). The method signature: public static void printSub2(String s) Note: All methods should be RECURSIVE. Any predefined classes that are based on Set are not allowed. Allow the user to input the string! In the main method, read a string from the user and output the reversed string and substrings to the screen: Sample Run: Please input a string: abcd The reversed string: dcba The substrings of the input string: abcd abc ab a b bc b c bcd bc b c cd c d The substrings of the input string: a ab abc…arrow_forwardThe files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. public classDebugSeven3 { public static void main(String[] args) { String quote = "Honesty is the first chapter in the book of wisdom. - Thomas Jefferson"; System.out.println("index.of('f') is: " + quoteindexOf('f')); System.out.println("index.of('x') is: " + quoteindexOf('x')); System.out.println("char.At(5) is: " + quote.charAt(50)); System.out.println("endsWith(\"daughter\") is: " + quote.endsWith("daughter")); System.out.println("endsWith(\"son\") is: " + quote.endsWith("son")); System.out.println("replace('e', '*') is: ", quote.replace('e', '*')); }arrow_forward
- basic java please Write a method dominant that accepts three integers as parameters and returns true if any one of the three integers is larger than the sum of the other two integers, otherwise it returns false. The integers might be passed in any order, so the largest value could be any of the three. If no value is larger than the sum of the other two, your method should return false. For example, the call of dominant(4, 9, 2) would return true because 9 is larger than 4 + 2. The call of dominant(5, 3, 7) would return false because none of those three numbers is larger than the sum of the others.arrow_forwardEvaluate the JAVA code snippet below, then motivate why this is representative ofgood programming practices or not.public class pattern{public static void main(string[] args){int rows = 5;for(int i = 1; i <= rows; ++i){for(int j=1;j<=I;++j){system.out.print(“*”);}System.out.println();}}arrow_forwardDetermine the output for the following code. Box in your final output result. public class Beta extends Baap { public int h = 44; public int getH( ) { System.out.println("Beta " + h); return h; } public static void main(String[ ] args) { Baap b = new Beta(); System.out.println(b.h + " " + b.getH( )); Beta bb = (Beta) b; System.out.println(bb.h + " " + bb.getH( )); } } public class Baap { public int h = 4; public int getH( ) { System.out.println("Baap " + h); return h; } }arrow_forward
- The following code is supposed to calculate 1/1^2 + 1/2^2 + 1/3^2 +…+ 1/9^2 + 1/10^2. However, there is a bug. In order to fix it, we need add this code ____ in line ____ Clarification: 1/2^2 means 1/4, 1/3^2 means 1/9 Note: The numbers on the left are line numbers for reference only and are not part of the code. 1 public class Example2 2 { 3 public static main (String[] args) 4 { 5 double sum = 0; 6 int num = 1; 7 while (num < 10) 8 { 9 sum = sum + 1.0/(num*num); 10 } 11 System.out.println(sum); 12 } 13 } Enter the code needed to fix the program above and the line where to insert it:arrow_forwardIN JAVA The following program generates an error. Why? public static void printSum(int num1, int num2) {System.out.print(num1 + num2);}public static void main(String args[]) {int y;y = printSum(4, 5); return 0;} A. printSum() is missing a "return;" statement. B. The values 4 and 5 cannot be passed directly to printSum() C. main() has a return statement that returns the value 0 D. printSum() has void return type, so cannot be assigned to a variablearrow_forwardWrite java program that will calculate the amount to be paid for electrical consumption. This problem is to handle electric billing for customers. The billing is depending on the type of the customer account. There are two types of customers account; i) fixed rate method and 2) variable rate method in the case of fixed rate method. The minimum monthly charge of RM20.00 is assessed if the consumption is less than or equal 100 kwh( kilowatt-hours). Otherwise, the rate of RM 0.22 per kWh is charged for the first 100 kWh and the rate of RM 0.33 per kWh is charged for the additional consumption. In the case of variable rate method, the rate of RM 0.22 per kWh is charged for the consumption less than or equal to 100 kWh. Any additional consumption is charged at RM 0.35 per kWh.arrow_forward
- Explain the following code.public class A{public void m(){System.out.println("Inside class A");}}public class B extends A{public void m(){System.out.println("Inside class B");}}public class StaticMethodTest{public static void main(String args[]){A ra1 = new A();A ra2 = new B();B rb = new B();ra1.m();ra2.m();rb.m();System.out.println();ra1 = ra2;ra1.m();System.out.println();//A.m();//B.m();}}arrow_forwardPlease explain what kind of syntax errors or problems the following statements might have. 1 = x; __________________ int X = 3.0.; __________________ char ch = "a"; __________________ int a==l; __________________ int if=3; __________________ What is the value of each output statement? Please write your answers on the· provided line. public class Evaluation { public static void main(String arg[]) {int X=l0 , i; for (i=0; i<3; i++)X=X-2;System.out.println(i); System.out.println(x);int h=0;do {h= h+3;} while (h<2');System.out.println(h);int k=2;while (k <2 ) {k= k+3;}System.out.p~ihtln (k);arrow_forwardWhat is the printout of the following code? public class Test { public static void main(string[] args) { int[][] matrix = {{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}, {12, 13, 14, 15}}; for (int i = 0; i < 4; i++) System.out.print(matrix[1][i] + " "); }}arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education