-
Lesson 2 - Entering and Running a Project
- Project - New Project
-
This program uses the scanner class for keyboard input. it lets you enter 3 numbers and prints out the average
import java.util.Scanner;
import java.io.*;
public class lesson1
{
static Scanner in = new Scanner(System.in);
public static void main() {
int n1,n2,n3;
double avg;
System.out.print("Enter a number ");
n1 = in.nextInt();
System.out.print("Enter a number ");
n2 = in.nextInt();
System.out.print("Enter a number ");
n3 = in.nextInt();
avg = (n1 +n2+n3)/3;
System.out.println("Average is "+avg);
}
}
-
Double click on it to Edit it
-
Compile it
-
Right mouse click and highlight function you want to run (void main)
|
|