Can someone help me with this?

Can someone help me with this?

I have this project and i dont know how to do it. Can someone help me? please?

Write a java class named "PAMA" which define a main () method that performs simple arithmetic. (e.g. Add, Subtract, Multiply, Divide)

Help me please! Thanks in advance!

View Answers

August 17, 2011 at 2:36 PM

import java.util.*;
class PAMA
{
    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);
    }
}

August 17, 2011 at 2:47 PM

it doesnt work.. btw thanks for the time.. i was wondering if you could make it simpler like this one.. this is our examples but i cant make it do simple arithmetics.. Thanks!

/* * SUPERMAN */ public class SUPERMAN { public static void main (String [] args) { string sentence1 = "I'm only a \"MAN\""; string sentence2 = "In a funny \RED SHEET\"; string sentence3 = "I'm only a man"; string sentence4 = "Looking for a " ' a DREAM""; System.out.println(sentence); } }


August 17, 2011 at 2:50 PM

it doesnt work.. btw thanks for the time.. i was wondering if you could make it simpler like this one.. this is our examples but i cant make it do simple arithmetics.. Thanks!

/*
* SUPERMAN 
*/ 
 public class SUPERMAN 
 { 
       public static void main (String [] args) 
       { 
       string sentence1 = "I'm only a \"MAN\""; 
       string sentence2 = "In a funny \RED SHEET\"; 
       string sentence3 = "I'm only a man"; 
       string sentence4 = "Looking for a " ' a DREAM"";
       System.out.println(sentence); 
       } 
 }









Related Tutorials/Questions & Answers:
Advertisements

Ads