Type the following code into a file called TotalAndAverage.java. After the program is entered, compile and run the application to make sure it works. Once you see it working correctly, answer questions a)-e) below. (The comment block shown here is a good example to base yours off of for Part 2, Program #2, namely Assignment1.java). DO NOT submit this file.
//***********************************************************
// Name: ASU CSE110 Instructor
// Title: TotalAndAverage.java
// Author: (if not you, put the name of author here)
// Description: Calculate the total and average scores.
// Time spent: 20 minutes
// Date:1/13/2016
//***********************************************************
public class TotalAndAverage {
public static void main(String[] args) {
final int count = 5;
int score0 = 98;
int score1 = 100;
int score2 = 80;
int score3 = 62;
int score4 = 77;
double total = score0 + score1 + score2 + score3 + score4;
double average = total / count;
System.out.println("Total Score is: " + total);
System.out.println("Average Score is: " + average);
}
}
There are numerous opportunities for errors in any program, many times in places that seem too simple to require close attention.
Questions: Introduce the following errors, one at a time, in the program TotalAndAverage.java. Explain any error messages that the compiler produces in your own words. Fix the previous error each time before you introduce a new one. If no error messages are produced, try to run the code and explain what happens. If still no errors are produced, explain whether the output is valid or not and why
a. Change TotalAndAverage to totalAndAverage.
b. Remove the first quotation mark in the first string literal in the first println( )statement.
c. Add three more semicolons (;) at the end of the first println( ) statement.
d. Remove the last brace in the program.
e. Change the variable type of total from double to int.
Note: The answers to the 5 questions (a through e) above should be typed in the block of comments in the Assignemnt1.java file such as;
/*
a) It was not compiled successfully because …
b) It does not generate any compile-error, but…
…
*/
Write a Java program called Assignment1.java, which prints the calendar of your birthday month. Declare the variables and initialize the values of: 1) your first name, 2) last name, and 3) birthday. Use the println and print methods and show the information in the following format.
The first and second lines print the first name and last name (3 pts). The third line shows the birthday and year with double- quotations (") (3 pts). The forth line is a blank line (3 pts). From the fifth line, display the calendar of your birthday month (3 pts). Use "t" to set the alignments for each day of week as shown in the example below (3 pts for alignments). You can find the calendar of your birthday year at http://www.timeanddate.com/.
*) A backslash () is used as an escape character in String literals. It causes an "escape" from the normal way characters are interpreted by the complier. For example, a character set of backslash and double-quotation " in string literals is recognized as a double-quotation " by the compiler. The backslash and letter-t (t) and the backslash and letter-n (n) are used to make an indent and change the line.
Example Execution:
The following is an example output. Use the other game character.
First Name: Barack
Last Name: Obama B
irthday: "August 1st, 1961"
August 1961
SU M T W TH F SA
---- ---- ---- ---- ---- ---- ----
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
For this and all subsequent assignments, provide a heading (in comments) described above and demonstrated in Program#1. Make sure your program is called Assignment1.java