SHARING KNOWLEDGE EACH OTHERS!

Wednesday, December 31, 2008

scanner function(average)


import java.util.Scanner;

public class calculationoftwoinput
{
//-----------------------------------------------------------------
// calculate two inputs.
//-----------------------------------------------------------------
public static void main (String[] args)
{
int mark1;
int mark2;
int total;
double average;

Scanner scan = new Scanner (System.in);

System.out.print ("Enter mark1: ");
mark1 = scan.nextInt();

System.out.print ("Enter mark2: ");
mark2 = scan.nextInt();

total = mark1 + mark2;
average = total/2;

System.out.println ("Total mark is : " + total);
System.out.println ("Average mark is: " + average);
}
}
GO TO CHAPTER 3

Stumble
Delicious
Technorati
Twitter
Facebook

0 Comments:

Post a Comment

Enter your email address:

 

SOFTWARES AND PLATFORMS Copyright © 2010 LKart Theme is Designed by Lasantha