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!
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); } }
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); } }
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
Questions by Category
- Swing-AWT
- Date-Calendar
- JDBC
- Regex
- XML
- Security
- Java Server Faces
Questions
- JSP Servlet
- EJB
- JavaMail
- JMS
- Java3D
- Log4J
- Spring
- Hibernate
- Maven
- IDE Questions
- Mobile
Applications
- Ajax
- Framework
- Struts
- WebSevices
- Java Magazine
- JSP-Interview Questions
- Java
Interview Questions
- Servlet Interview Questions
-
Hibernate Interview Questions
- JUNIT
- Java Beginners
- Applet
- JNDI
- RMI
- LDAP
- RUP
- UML
- SQL
-
Design concepts & design patterns
- Ant
- CVS
- Subversion
- Development
process
- AOP
- IoC
- PHP