Codingitis

Codingitis

Share

CODINGITIS-PROVIDES A PLATFORM TO LEARN VARIOUS COMPUTER LANGUAGES LIKE C ,C++,PYTHON,JAVA INTERMEDIATE ETC.

Photos 28/02/2016

Will the following code compile? If yes, then is there any other problem with this code?

22/02/2016

//Simple calculator program in java...........!

import java.util.Scanner;
import java.lang.*;
class Calculator2
{

public static void main(String[] args)
{
int a;
int b;
Scanner input = new Scanner(System.in);

do
{
System.out.println("Enter 1 for addition ");
System.out.println("Enter 2 for subtraction ");
System.out.println("Enter 3 for multiplication ");
System.out.println("Enter 4 for Devision ");
System.out.println("Enter 5 for Exit");

int number = input.nextInt();

switch (number) {

case 1:
System.out.print("Enter First number ");
a = input.nextInt();
System.out.print("Enter Second number ");
b =input.nextInt();
System.out.println("Addition ="+ a+b);
break;

case 2:
System.out.print("Enter First number ");
a = input.nextInt();
System.out.print("Enter Second number ");
b =input.nextInt();
System.out.println("Subtraction ="+ (a-b));
break;

case 3:
System.out.print("Enter First number ");
a = input.nextInt();
System.out.print("Enter Second number ");
b =input.nextInt();
System.out.println("multiplication ="+ a*b);
break;

case 4:
System.out.print("Enter First number ");
a = input.nextInt();
System.out.print("Enter Second number ");
b =input.nextInt();
System.out.println("Devision ="+ a/b);
break;

case 5:
System.exit(0);
}}

while (true);
}
}

Want your business to be the top-listed Computer & Electronics Service in Gorakhpur?
Click here to claim your Sponsored Listing.

Telephone

Address


Golghar
Gorakhpur
273001