Results 1 to 5 of 5
Thread: Need help!!!!!!
- 10-05-2010, 06:24 AM #1
Member
- Join Date
- Sep 2010
- Location
- Singapore
- Posts
- 13
- Rep Power
- 0
Need help!!!!!!
I need to create a calculator program on JCreator and it must have a printout similar to this program:
import java.io.*;
public class dowhilecode {
public static void main(String[] args)throws IOException {
BufferedReader abc=new BufferedReader (new InputStreamReader (System.in));
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");
System.out.println("");
System.out.println("Choose a menu option");
int numberone=Integer.parseInt(abc.readLine());
System.out.println("");
System.out.println("Enter the first number");
int numbertwo=Integer.parseInt(abc.readLine());
System.out.println("");
System.out.println("Enter the second number");
int numberthree=Integer.parseInt(abc.readLine());
switch(numberone)
{
case 1: //addition
System.out.println(numbertwo+"+"+numberthree+"="+( numbertwo+numberthree));
break;
case 2: //subtraction
System.out.println(numbertwo+"-"+numberthree+"="+(numbertwo-numberthree));
break;
case 3: //multiplication
System.out.println(numbertwo+"x"+numberthree+"="+( numbertwo*numberthree));
break;
case 4: //division
System.out.println(numbertwo+"/"+numberthree+"="+(numbertwo/numberthree));
break;
case 5: //exit
System.out.println("Exiting Program");
break;
}
}
}
Except that I must use functions instead of just cases and dowhile code. The code above prints the menu then you choose an option with an integer and then it asks you for 2 numbers and depending on the menu option you chose it will calculate the answer, unless of course you chose exit.
However in the new and improved calculator using functions I must print the same thing except it must ask if you wish to continue with more calculations at the end where it loops back to the menu or exits.
Plz help I only have 2-3 days to do this. If there is trouble understanding what I need to do then you can ask me.
-
You may wish to reply to helpful replies in your previous thread, since without them, we can only assume that you never read them and will likewise not read replies in this thread. Also, you may with to show us your attempt to solve your current problem as well as describe in greater detail just what is currently tripping you up.
Much luck.
- 10-06-2010, 06:28 AM #3
Member
- Join Date
- Sep 2010
- Location
- Singapore
- Posts
- 13
- Rep Power
- 0
I did, its only cus it took me a while to work it out.
- 10-06-2010, 02:18 PM #4
Your meaningless post title is going to prevent a lot of people from even viewing your thread. Of the few who will actually view the thread, your unformatted code will send most of them packing without reading any further. Of the couple of people who do read your post, saying things like "Plz help I only have 2-3 days to do this." will annoy them enough that they no longer want to help.
- 10-28-2010, 08:25 AM #5
Member
- Join Date
- Sep 2010
- Location
- Singapore
- Posts
- 13
- Rep Power
- 0
Bookmarks