Results 1 to 8 of 8
Like Tree1Likes
  • 1 Post By jim829

Thread: i have no idea what i'm doing...

  1. #1
    Joshidc is offline Member
    Join Date
    Jan 2014
    Location
    Iloilo, Philippines
    Posts
    5
    Rep Power
    0

    Unhappy i have no idea what i'm doing...

    hi guys i've got a question... im new to java and i wanna make a program using java that can add order entries for a restaurant but the problem is i have no idea how to... i was hoping something that would ask to person to input one or two items and before it calculates the total amount to be paid it will ask the guy who inputs the amount whether or not there are additional orders or not before it prints out the total amount... im pretty sure it will need an if-else statement... this is all i could come up with the whole 3 days...

    import javax.swing.*;
    import java.util.Scanner;

    public class OrderCalc {
    JFrame.setDefaultLookAndFeelDecorated(true);
    JFrame aFrame = new JFrame("OrderCalc");
    aFrame.setSize(500,250);
    aFrame.setVisible(true);
    }

    public static void main (String[] args) {
    do{
    if {System.out.println("Please enter first order:");
    Scanner Order = new Scanner(System.in);

    }

    }

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default Re: i have no idea what i'm doing...

    Hi,
    read this on how to format code here: Guide For New Members

    You're making a common beginner mistake. You want to do it all at once. Start step by step: 1) output what the user issupposed to enter , 2) read one single input from the user, 3) output what was entered 4) do some calculation 5) outut the result from 4.

    After all that you can start thinking about multiple inputs.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    Joshidc is offline Member
    Join Date
    Jan 2014
    Location
    Iloilo, Philippines
    Posts
    5
    Rep Power
    0

    Default Re: i have no idea what i'm doing...

    ok thanks for the guide and the steps... i've read steps 1-5 and this is what i came up with... im really sorry about bothering you guys... im just really new to this and everything is still pretty confusing since i've only got youtube for the tutorials... :(

    Java Code:
    import javax.swing.*;
    import java.util.Scanner;
    import javax.swing.JFrame;
    
    public class OrderCalc {
    	JFrame.setDefaultLookAndFeelDecorated(true);
    	JFrame aFrame = new JFrame("OrderCalc");
    	aFrame.setSize(500,250);
    	aFrame.setVisible(true);
    }
    	
    	public static void main (String[] args) {
    		Scanner Order = new Scanner(System.in);
    		double fnum,snum,tnum,qnum,pnum,wnum,rnum,answer;
    		System.out.println("Enter First Order:");
    		fnum = Order.nextDouble();
    		System.out.println("Enter Second Order:");
    		snum = Order.nextDouble();
    		System.out.println("Are there more than 2 orders?")
    		String a = input.next();
    		if(a==Yes){
    			System.out.println("Enter Third Order:");
    			tnum = Order.nextDouble();
    			System.out.println("Is This The Last Order?");
    			
    			if (a==yes){
    				answer = fnum+snum+tnum
    				System.out.println("The Total Amount Would Be:" + answer);
    			}
    			else (a==no){
    				System.out.println("Enter Fourth Order:");
    				qnum = Order.nextDouble();
    				System.out.println("Is This The Last Order?");
    				
    				if (a==yes){
    				answer = fnum+snum+tnum+qnum
    				System.out.println("The Total Amount Would Be:" + answer);
    				}
    				else (a==no){
    				System.out.println("Enter Fifth Order:");
    				pnum = Order.nextDouble();
    				System.out.println("Is This The Last Order?");
    				
    					if (a==yes){
    					answer = fnum+snum+tnum+qnum+pnum
    					System.out.println("The Total Amount Would Be:" + answer);
    					}
    					else (a==no){
    					System.out.println("Enter Sixth Order:");
    					wnum = Order.nextDouble();
    					System.out.println("Is This The Last Order?");
    						
    							if (a==yes){
    							answer = fnum+snum+tnum+qnum+wnum;
    							System.out.println("The Total Amount Would Be:" + answer);
    							}
    							else (a==no){
    							System.out.println("Enter Seventh Order:");
    							rnum = Order.nextDouble();
    							answer = fnum+snum+tnum+qnum+wnum+rnum;
    							}
    					}
    				
    				}
    			}	
    		}
    		else (a==no){
    			answer = fnum+snum;
    			System.out.println("The Total Amount Would Be:"+ answer);
    		}
        }
    Last edited by Joshidc; 01-17-2014 at 01:58 PM.

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,354
    Rep Power
    6

    Default Re: i have no idea what i'm doing...

    so buy a good beginner book and make your life about a thousand times easier. Youtube tutorials are -perfect- to explain things where you need to click and drag. Youtube videos are -terrible- when it comes to explaining something that is heavily involved in theory. Learning a programming language involves very little clicking and dragging.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    Joshidc is offline Member
    Join Date
    Jan 2014
    Location
    Iloilo, Philippines
    Posts
    5
    Rep Power
    0

    Default Re: i have no idea what i'm doing...

    ok thanks. i really do have a lot of reading and studying to do concerning java. thanks again dude :)

  6. #6
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,018
    Rep Power
    6

    Default Re: i have no idea what i'm doing...

    You really need to go back to the basics (and like Gimbal said, get a book). Your a==Yes is wrong. What you probably meant was a=="Yes" which would still be wrong. You would need to do a.equals("Yes"). Strings are between double quotes and use equals, not ==, to test for equality of objects. A good place to start is the Java tutorials in my signature. But IMO, there is no substitute for a good book when learning a programming language.

    Regards,
    Jim
    gimbal2 likes this.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  7. #7
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,354
    Rep Power
    6

    Default Re: i have no idea what i'm doing...

    Quote Originally Posted by Joshidc View Post
    ok thanks. i really do have a lot of reading and studying to do concerning java. thanks again dude :)
    Thank you for listening. Now where is my car?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  8. #8
    Daryn is offline Senior Member
    Join Date
    Oct 2012
    Posts
    176
    Rep Power
    3

    Default Re: i have no idea what i'm doing...

    Although A little Wordy A good book to use is Thinking in Java by Brucke Eckel Bruce Eckel's MindView, Inc: Free Electronic Book: Thinking in Java, 3rd Edition you can download it for free. Like I said its a little wordy I only read the first like 6 chapters in order then I just started using it as a reference.
    With the right know how, anything is possible

Similar Threads

  1. I need a fun idea.
    By Scyth3 in forum Forum Lobby
    Replies: 2
    Last Post: 11-25-2012, 01:00 PM
  2. is this idea possible?
    By neoginn in forum New To Java
    Replies: 1
    Last Post: 10-12-2012, 07:52 AM
  3. I have no idea what I'm doing any more...
    By kaizen9001 in forum New To Java
    Replies: 1
    Last Post: 03-26-2011, 06:10 PM
  4. I have an idea !!
    By HosHos in forum New To Java
    Replies: 1
    Last Post: 08-12-2009, 07:38 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •