I have written some code in java to give the some of the numbers 1 to 10 and then also display the average. I would like to change this to the model view controller method(thats what the tutor wants). We only had one lesson on it and i dont really understand how do change it. If someone could go through this and show me how(as if they were trying to teach a 5 year old) that would be great.
//JAVA CODE
public class Ex4 {
public static void main(String[] args) {
int sum = 0;
int average = 0;
for (int i=1; i < 10; i++){
sum = sum + i;
average = sum/i;
}
System.out.println("The sum is " + sum);
System.out.println("The average is " + average);
}
}
Aucun commentaire:
Enregistrer un commentaire