I have this simple problem I'm trying to do. I'm trying to write a program that doubles these five numbers. Then I want to compute the average of these numbers and print them out. The code runs with no errors, but it will not print my answer for some reason. How can I get it to print the output of the problem or simply print something? I am using Netbeans.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package marina;
/**
*
* @author bax
*/
public class Precedence {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
double grade1 = 100;
double grade2 = 75;
double grade3 = 88;
double grade4 = 65;
double grade5 = 99;
int x = (int) (grade1+grade2+grade3+grade4+grade5/5.0);
System.out.println(x);
}
}
Output:
run:
BUILD SUCCESSFUL (total time: 0 seconds)
Shift + F6. Notice that if you press justF6then the main project will be run, not necessarily this project. Also, make sure you hit theClean and buildoption, to clean up cache and so on.