MeraForum Community.No 1 Pakistani Forum Community - View Single Post - CLASS 4: Calculator Using Switch Statement In Java
View Single Post
(#6)
Old
Morash's Avatar
Morash Morash is offline
 


Posts: 17,781
My Photos: ()
Country:
Star Sign:
Join Date: Jul 2010
Location: ▌║█║▌│█│║▌║
Gender: Male
Default Re: CLASS 4: Calculator Using Switch Statement In Java - >>   Show Printable Version  Show Printable Version   Email this Page  Email this Page   04-22-2014, 11:05 PM

Quote:
Originally Posted by AYAZ View Post
Morash check this code, It's giving me error don't know why

Code:
package cal;
import java.util.Scanner;

/**
 *
 * @author Ayaz
 */
public class cal
{

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        float num1 , num2;
String operations;

Scanner input = new Scanner (System.in);
System.out.print("Enter the First number");
num1 = input.nextFloat();

System.out.print("Enter the operation");
operations = input.next();

System.out.print("Enter the Second Number");
num2= input.nextFloat();

switch (operations){
    
    
    case "+":
    System.out.print("Addition of "+num1+"and "+num2+" is =  "+ (num1 + num2));
    break;

    case "-":
    System.out.print("Substraction of "+num1+"and "+num2+" is = "+ (num1 - num2));
    break;
    
    case "/":
    System.out.print ("Division of "+num1+" and "+num2+" is" = + (num1 / num2));
    break;

    case "*":
    System.out.print("Multiplication  of "+num1+" and "+num2+" is" = + (num1 * num2));
    break;


    

   }
    }}
Your Package And Cal Class Names Are Same, Change cal Class Name To Cal (Capital C)
Last 2 Jo System.out.print K Statements Hai Os Mai is K Saath Jo Double Commas Lage Hai, Wo Remove Karo And Equal Sign K Baad Lagana ..

 





bE driveN wiTh puRpOse, Be r313n71355 in your alιgnмenт;
with excellence.
pAy n0 mInd to the ∂ιsιмραssισηε∂ เ๓ק๏tєภt ђคtєгร

.. нoolιgan