Question
Prelab Exercises Your task is to write a Java program that will print out the following message (including the row of equal marks): Computer Science,
Prelab Exercises Your task is to write a Java program that will print out the following message (including the row of equal marks): Computer Science, Yes!!!! ========================= An outline of the program is below. Complete it as follows: a. In the documentation at the top, fill in the name of the file the program would be saved in and a brief description of what the program does. b. Add the code for the main method to do the printing. // ************************************************************ // File Name: // // Purpose: // ************************************************************ public class CSYes { // ------------------------------------------------- // The following main method prints an exciting // message about computer science // ------------------------------------------------- }
Comments File Count.java contains a Java program that counts from 1 to 5 in English, French, and Spanish. Save this file to your directory and compile and run it to see what it does. Then modify it as follows: 1. Use // style comments to add a comment header at the top of the file that includes the name of the program, your name, and a brief description of what the program does, neatly formatted. Include a delimiter line (e.g., all stars) at the beginning and end of the header. 2. Add a comment before each println that indicates what language the next line is in. Experiment with leaving a blank line before each of these comment lines (in the program itself, not the output). Is the program easier to read with or without these blank lines? 3. Remove one of the slashes from one of your comment lines and recompile the program, so one of the comments starts with a single /. What error do you get? Put the slash back in. 4. Try putting a comment within a comment, so that a // appears after the initial // on a comment line. Does this cause problems? 5. Consult the documentation guidelines in Appendix F of the text. Have you violated any of them? List two things that you could imagine yourself or someone else doing in commenting this program that these guidelines discourage. Count.java public class Count { public static void main (String[] args) { System.out.println ("one two three four five"); System.out.println ("un deux trois quatre cinq"); System.out.println ("uno dos tres cuatro cinco"); } }
Correcting Syntax Errors File Problems.java contains a simple Java program that contains a number of syntax errors. Save the program to your directory, study it and correct as many of the errors as you can find. Then compile the program; if there are still errors, correct them. Some things to remember:
Java is case sensitive, so, for example, the identifiers public, Public, and PUBLIC are all considered different. For reserved words such as public and void and previously defined identifiers such as String and System, you have to get the case right. You will learn the conventions about case soon, but for now you can look at a sample program in the text to see what case should be used where.
When the compiler lists lots of errors, fix the first one (or few) and then recompileoften the later errors arent really errors in the program, they just indicate that the compiler is confused from earlier errors.
Read the error messages carefully, and note what line numbers they refer to. Often the messages are helpful, but even when they arent, the line numbers usually are.
When the program compiles cleanly, run it. // ******************************************** // Problems.java // // Provide lots of syntax errors for the user to correct. // ******************************************** public class problems { public Static main (string[] args) { System.out.println ("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); System.out.println ("This program used to have lots of problems,"); System.out.println ("but if it prints this, you fixed them all.") System.out.println (" *** Hurray! ***"); System.out.println ("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started