Computer Science Canada Desperate for help with Comp Sci Lab (Intro) |
Author: | gully3 [ Sat Sep 22, 2012 6:23 pm ] |
Post subject: | Desperate for help with Comp Sci Lab (Intro) |
I am a student in intro Comp Sci and am trying to complete a lab, we use and I am using NX Client for windows. Here is the lab assignment: Lab #2 Open the file Average3.java. Compile and run Average3.java and observer the output. Add a third variable, num3 to the average calculation. Have the program ask the user for the value of this number. This activity includes the following steps: Create an integer variable named num3. Ask the user to enter a value for num3. Read the number the user enters. (Remember what changes you need to make in order to get a program to do input!) Modify the average calculation to include num3. (You are now finding the average of three numbers.) Modify the output statements as appropriate. Compile and run the program. If you encounter any errors (syntax or logic) that you can not resolve, ask the lab instructor for help. Your output should match the one given by the Sample class: SampleAverage3.class. When your program works correctly, zip Average3.java and Average3.class to lab3.zip, then submit through moodle ///////////////////////////////////////////////// // Author: Peng Zhang // Objective: // The following program should be modified // according to the assignment statement. // Date: September 2, 2010 //////////////////////////////////////////////// public class Average3 { public static void main(String[] args) { // Create integer variables named num1 and num2 int num1 = 75; int num2 = 137; // Compute the average of num1 and num2 double average = (num1+num2)/2.0; // Output the result System.out.println("The average of "+num1); System.out.println("and "+num2+" is "+average); } } |
Author: | Tony [ Sat Sep 22, 2012 6:51 pm ] |
Post subject: | Re: Desperate for help with Comp Sci Lab (Intro) |
It seems that the first step being asked of you is gully3 @ Sat Sep 22, 2012 6:23 pm wrote: Create an integer variable named num3.
Are you asking for help with creating an integer variable with a specific name? |