2/02/2015

BCS2233 OOP 2BCNS SEM 2 14/15 LAB WEEK 2

Write a program to input 2 integers and print the average.

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:

Cara download Installer windows 10 dalam format ISO

1. Jika anda bercadang untuk download windows 10 melalui website rasmi windows - pilihan untuk download dalam format ISO tidak di berikan.  ...