I. Pseudocode
1. INPUT two integers (N1,N2)
2. CALCULATE Average
Average = (N1+N2) /2
3. OUTPUT Average
II. Flowchart
III. Java Program
import java.util.Scanner; //to read input from console
public class bcnslabweek2 {
public static void main(String[] args) {
//declare variable
int N1,N2;
double AVG;
Scanner input = new Scanner(System.in);
//get input
System.out.println("Please enter two integers ");
N1 = input.nextInt();
N2 = input.nextInt();
//calculate average
AVG =(N1+N2)/2.0;
//print output
System.out.println("Average = " + AVG);
}
}
No comments:
Post a Comment