One sample java sudo code that can help you to take no of scores (ex: subject scores which can be decimal values) that user want to enter and to display avg of that score:public class Test {public static void main(String args[]) {BufferedReader br=new BufferedReader(new InputStreamReader(System.in));// Syso means System.out.printlnsyso("Please enter no of test scores that you want to enter:");int n=Integer.parseInt(br.readLine());Double[] testScores = new Double[n];Double avgVar = 0.0;for(loop upto n times) {syso("Enter score:");testScores[loopVar] = Double.parseDouble(br.readLine());avgVar+=testScores[loopVar];}syso("Your avg score is:" + avgVar/n);That is it....
Post a Comment
1 comment:
One sample java sudo code that can help you to take no of scores (ex: subject scores which can be decimal values) that user want to enter and to display avg of that score:
public class Test {
public static void main(String args[]) {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
// Syso means System.out.println
syso("Please enter no of test scores that you want to enter:");
int n=Integer.parseInt(br.readLine());
Double[] testScores = new Double[n];
Double avgVar = 0.0;
for(loop upto n times) {
syso("Enter score:");
testScores[loopVar] = Double.parseDouble(br.readLine());
avgVar+=testScores[loopVar];
}
syso("Your avg score is:" + avgVar/n);
That is it....
Post a Comment