November 2nd, 2012, 05:18 PM
I need a help to solve my assinment, and i tried many times but i couldn't
1. Write a Java program to read a Name,ID and marks for 5 courses. Find the Total and Average of 5 courses. Display the values of all variables.
Hint: Use for loop to get the input for 5 marks. Donít use 5 different variables.
but here i couldn't solve it(the red one)
public static void main(String arg)
int ID,mark,a,sum=0 ;
Scanner S=new Scanner(System.in);
System.out.println("Enter your name");
System.out.println("Enter your ID");
System.out.println("enter the values");
7.Write a java program to find the square root of every number between 1 and 20.Use any loop.
8.Consider the following expression.
Read appropriate inputs and display the output.
November 5th, 2012, 08:22 AM
Please edit your post and wrap the code in code tags.
To find the total, you need to add up all the numbers that are read in. Define a variable to hold the total, initialize it to 0 and then add each number to it.
To find the average, you need to count the number of numbers read and then divide the total by the number of numbers that were read in.