programes on switch

programes on switch

  1. write a program to design menu driven arithmetic calculator
  2. write a program to print no of days in a given month
View Answers

March 26, 2011 at 1:22 PM

import java.util.*;
class Calculator
{
    public static void main(String[] args) 
    {
        boolean exit=false;
        Scanner input=new Scanner(System.in);
        System.out.print("Enter number1: ");
        double num1=input.nextDouble();
        System.out.print("Enter number2: ");
        double num2=input.nextDouble();
        System.out.println("1 Addition");
        System.out.println("2 Subtraction");
        System.out.println("3 Multiplication");
        System.out.println("4 Division");
        System.out.println("5 Exit");
        do{
            System.out.print("Enter your choice: ");
            int choice=input.nextInt();
            switch(choice){
                case 1: 
                    double add=num1+num2;
                    System.out.println("Addition="+add);
                    break;
                case 2: 
                    double sub=num1-num2;
                    System.out.println("Subtraction="+sub);
                    break;
                case 3: 
                    double mul=num1*num2;
                    System.out.println("Multiplication="+mul);
                    break;
                case 4: 
                    double div=num1/num2;
                    System.out.println("Division="+div);
                    break;
                case 5: 
                    exit=true;
                    break;
            }
        }
        while(!exit);
    }
}

March 26, 2011 at 1:24 PM









Related Tutorials/Questions & Answers:
programes on switch
programes on switch   write a program to design menu driven arithmetic calculator write a program to print no of days in a given month   ...=input.nextInt(); switch(choice){ case 1
programes on for loop
programes on for loop  a. write a program to find squares and cubes of 1st 10 integers b. write a program to to calculate factorial of a no, c. write a program to print Fibonacci series d. write a program to check whether entered
Advertisements
programes on for loop
programes on for loop  a. write a program to find squares and cubes of 1st 10 integers b. write a program to to calculate factorial of a no, c. write a program to print Fibonacci series d. write a program to check whether entered
programes on for loop
programes on for loop  a. write a program to find squares and cubes of 1st 10 integers b. write a program to to calculate factorial of a no, c. write a program to print Fibonacci series d. write a program to check whether entered
programes on for loop
programes on for loop  a. write a program to find squares and cubes of 1st 10 integers b. write a program to to calculate factorial of a no, c. write a program to print Fibonacci series d. write a program to check whether entered
programes on methods
programes on methods   write a program to implement bubble sort write a program to demonstrate call by value and call by reference.(pass objects as parameters) write a program to calculate factorial of a no. using recursive
programes on array
programes on array  a. write a program to find max and min element in an array of an integer b. write a program to convert decimal no. to binary... = input.nextInt(); System.out.println(); switch(menu) { case 1
programes on strings
programes on strings   a. write a program to copy one array to another array using System.arrayCopy() method. b. write a program to check whether entered string is palindrome or not.   Have a look at the following link
programes on if....else
programes on if....else   write a program to check whether entered year is leap year or not write a program to check whether entered no. ends with 5 or not write a program to find minimum of 3 nos using nested if else. write
programes on while loop
programes on while loop   write a program to calculate sum of an entered digit write a program to find gcd and lcm of 2 positive integers   Java sum of digits Java Find LCM and GCD
programes on do... while
programes on do... while   write a program to print reverse of a given digit write a program to check whether entered digit is palindrome or not write a program to check whether entered no. is Armstrong or not   1
switch statement
switch statement   i want to write a java program that computes Fibonacci,factorial,string reversal and ackerman using switch case to run as a single program
switch case
switch case  program to input 2 numbers and a choice.Using switch case we need to perform all the mathematical operation.Print a suitable error message if the choice is wrong
switch case
switch case  program to input 2 numbers and a choice.Using switch case we need to perform all the mathematical operation.Print a suitable error message if the choice is wrong
Switch databases
Switch databases  How do you inter-change between relational databases without code changes
Switch
Switch      ... statements. To avoid this we can use Switch statements in Java. The switch statement... of a variable or expression. The switch statement in Java is the best way to test
The Switch statement
Switch       Sometimes.... To avoid this we can use Switch statements in Java. The switch statement is used... of a variable or expression. The switch statement in Java is the best way to test
Switch Statement
Switch Statement  How we can use switch case in java program ?   Note:-Switch case provides built-in multiway decision statement.It...); switch(days){ case 1: System.out.println("Sunday
Switch Statement with Strings in Java
Switch Statement with Strings in Java  Switch Statement with Strings in Java
Java switch statement
Java switch statement  What restrictions are placed on the values of each case of a switch statement
switch case instead of if else
switch case instead of if else  How to write code in switch case instead of if else in Java
ModuleNotFoundError: No module named 'switch'
ModuleNotFoundError: No module named 'switch'  Hi, My Python... 'switch' How to remove the ModuleNotFoundError: No module named 'switch'... to install padas library. You can install switch python with following command
ModuleNotFoundError: No module named 'switch'
ModuleNotFoundError: No module named 'switch'  Hi, My Python... 'switch' How to remove the ModuleNotFoundError: No module named 'switch'... to install padas library. You can install switch python with following command
Switch statement in PHP
Switch statement in PHP  HII, Explain about switch statement in PHP?   hello,ADS_TO_REPLACE_1 Switch statement is executed line by line... of the switch expression. It does execute the statement until the end of the block
using switch,break and for loop
using switch,break and for loop  generate a 10 digit number and display the length of longest increasing series
using switch and break
using switch and break  generate a 10 digit number and display the length of longest increasing series
Switch case + condition??
Switch case + condition??  I try to use a switch case with condition but it doesn't display anything have look: ......public void commandAction...(); } } else { List down = (List)display.getCurrent(); switch
using switch case
using switch case  Define a class MENU to perform the following operation depending upon the users choice using switch case 1)print square root... choice: "); int choice=input.nextInt(); switch(choice
Switch case in Jsp page
Switch case in Jsp page  <table> <tr><td>Enter Distance :</td> <td><input type="text" name="dis"/></td>... using switch case in jsp page
ModuleNotFoundError: No module named 'e-switch'
ModuleNotFoundError: No module named 'e-switch'  Hi, My Python...-switch' How to remove the ModuleNotFoundError: No module named 'e-switch... to install padas library. You can install e-switch python with following
ModuleNotFoundError: No module named 'js.bootstrap-switch'
ModuleNotFoundError: No module named 'js.bootstrap-switch'  Hi, My... named 'js.bootstrap-switch' How to remove the ModuleNotFoundError: No module named 'js.bootstrap-switch' error? Thanks   Hi
ModuleNotFoundError: No module named 'mongo-switch'
ModuleNotFoundError: No module named 'mongo-switch'  Hi, My Python... 'mongo-switch' How to remove the ModuleNotFoundError: No module named 'mongo-switch' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'nose-switch'
ModuleNotFoundError: No module named 'nose-switch'  Hi, My Python... 'nose-switch' How to remove the ModuleNotFoundError: No module named 'nose-switch' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'pulseaudio-switch'
ModuleNotFoundError: No module named 'pulseaudio-switch'  Hi, My... named 'pulseaudio-switch' How to remove the ModuleNotFoundError: No module named 'pulseaudio-switch' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'smt-switch'
ModuleNotFoundError: No module named 'smt-switch'  Hi, My Python... 'smt-switch' How to remove the ModuleNotFoundError: No module named 'smt-switch' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'switch-inputs'
ModuleNotFoundError: No module named 'switch-inputs'  Hi, My... 'switch-inputs' How to remove the ModuleNotFoundError: No module named 'switch-inputs' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'switch-model'
ModuleNotFoundError: No module named 'switch-model'  Hi, My Python... 'switch-model' How to remove the ModuleNotFoundError: No module named 'switch-model' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'switch-payments'
ModuleNotFoundError: No module named 'switch-payments'  Hi, My... named 'switch-payments' How to remove the ModuleNotFoundError: No module named 'switch-payments' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'ybc-switch'
ModuleNotFoundError: No module named 'ybc-switch'  Hi, My Python... 'ybc-switch' How to remove the ModuleNotFoundError: No module named 'ybc-switch' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'enum-switch'
ModuleNotFoundError: No module named 'enum-switch'  Hi, My Python... 'enum-switch' How to remove the ModuleNotFoundError: No module named 'enum-switch' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'e-switch'
ModuleNotFoundError: No module named 'e-switch'  Hi, My Python...-switch' How to remove the ModuleNotFoundError: No module named 'e-switch... to install padas library. You can install e-switch python with following
ModuleNotFoundError: No module named 'enum-switch'
ModuleNotFoundError: No module named 'enum-switch'  Hi, My Python... 'enum-switch' How to remove the ModuleNotFoundError: No module named 'enum-switch' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'pi_switch'
ModuleNotFoundError: No module named 'pi_switch'  Hi, My Python..._switch' How to remove the ModuleNotFoundError: No module named 'pi_switch' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'switch-case'
ModuleNotFoundError: No module named 'switch-case'  Hi, My Python... 'switch-case' How to remove the ModuleNotFoundError: No module named 'switch-case' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'switch-case'
ModuleNotFoundError: No module named 'switch-case'  Hi, My Python... 'switch-case' How to remove the ModuleNotFoundError: No module named 'switch-case' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'switch-mexico'
ModuleNotFoundError: No module named 'switch-mexico'  Hi, My... 'switch-mexico' How to remove the ModuleNotFoundError: No module named 'switch-mexico' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'ugly-switch'
ModuleNotFoundError: No module named 'ugly-switch'  Hi, My Python... 'ugly-switch' How to remove the ModuleNotFoundError: No module named 'ugly-switch' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'Flask-Switch'
ModuleNotFoundError: No module named 'Flask-Switch'  Hi, My Python... 'Flask-Switch' How to remove the ModuleNotFoundError: No module named 'Flask-Switch' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'js.bootstrap-switch'
ModuleNotFoundError: No module named 'js.bootstrap-switch'  Hi, My... named 'js.bootstrap-switch' How to remove the ModuleNotFoundError: No module named 'js.bootstrap-switch' error? Thanks   Hi
Version of com.braintreepayments>browser-switch dependency
List of Version of com.braintreepayments>browser-switch dependency

Ads