Results 1 to 7 of 7
  1. #1
    CTimpsonS is offline Member
    Join Date
    Aug 2015
    Posts
    3
    Rep Power
    0

    Default Starting a New Project

    I am new to Java coding... I am starting a new project using Eclipse. How/where would my entry be placed which will one to receive total cost?


    /**
    * Course: IT110 - Introduction to Programming
    * Filename: TCSInternationalPhase1.java
    * Created: 08/24/2015 by Clifford Timpson Sr.
    * Modified:
    *
    * Purpose: Created a simple online ordering system
    * for TCS International customers
    */

    import java.util.Calendar;

    import javax.swing.JOptionPane;

    /**
    * @author Clifford Timpson, Sr.
    */
    public class TimpsonPhase1 {

    /**
    * @param <Date>
    * @param args
    */

    public static void main(String[] args) {

    // declare variables
    String openingMsg, nameInputMsg, customerName, nameOutputMsg, returnInputMsg, customerReturn, productReturn, returnOutputMsg, productOutputMsg, costReturn, costOutputMsg, quantityReturn, quantityOutputMsg, greetingOutputMsg, outputMsg;

    // display opening message
    openingMsg = "*** Welcome to the Timpson Online Ordering System ***\n"
    + " Your day just got Amazing!";
    JOptionPane.showMessageDialog(null, openingMsg);

    // getStringInput()
    nameInputMsg = "Please enter your name: ";
    customerName = JOptionPane.showInputDialog(nameInputMsg);
    returnInputMsg = "Are you a returning customer (yes or no)? ";
    customerReturn = JOptionPane.showInputDialog(returnInputMsg);
    returnInputMsg = "Which product would you like to order? ";
    productReturn = JOptionPane.showInputDialog(returnInputMsg);
    returnInputMsg = "Enter Qauntity (1-99)? ";
    quantityReturn = JOptionPane.showInputDialog(returnInputMsg);
    returnInputMsg = "Your total will be ";
    costReturn = JOptionPane.showInputDialog(returnInputMsg);

    // build output strings
    nameOutputMsg = "Welcome " + customerName + ".\n\n";
    returnOutputMsg = "Your return customer status is " + customerReturn + ".\n";
    productOutputMsg = "Your selection is " + productReturn + ". \n";
    quantityOutputMsg = "Number of items ordered " + quantityReturn + ". \n";
    costOutputMsg = "Total Bill " + costReturn + ". \n";
    greetingOutputMsg = "Thank you for visiting Timpson's Online Store!" + "\n"
    + "*** Your day just got amazing. ***\n\n";

    // create and display output string
    outputMsg = nameOutputMsg + returnOutputMsg + productOutputMsg + quantityOutputMsg + costOutputMsg + greetingOutputMsg;
    JOptionPane.showMessageDialog(null, outputMsg);

    System.exit(0);
    } // end main()

    } // end class TimpsonPhase1

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Starting a New Project

    Please edit your post and wrap the code in code tags.

    to receive total cost?
    What is "total cost"? Is it entered by the user or computed by the program?
    Can you explain what the code is supposed to do and the steps it will take to do it?
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    CTimpsonS is offline Member
    Join Date
    Aug 2015
    Posts
    3
    Rep Power
    0

    Default Re: Starting a New Project

    Norm, thank you.

    Not sure what you're requesting about code tags. I am up to learning.
    The program should return the "total cost"
    Some additional information:
    Define the method called getStringInput( ) using the method header:

    private static String getStringInput(String prompt)

    This method must do the following:

    Use JOptionPane.showInputDialog( ) to display the prompt.
    Check the value that is returned.
    If the value is null, the program should terminate.
    If the value is a nonempty string, that string should be returned as the value of the method.
    Otherwise, this request sequence should be repeated up to 3 times.
    If the customer has not entered a valid input by then, the program should make an appropriate comment and then terminate.

    Then replace my existing code that requests the customer's name, return status, and color with calls to getStringInput( ).

    Add a request for quantity, or the number of items that the customer wishes to order. Use getStringInput( ) to obtain this value from the customer. You will need to convert the quantity string into an int value. You should use the Integer.parseInt( ) method to accomplish this.

    Create a method called totalCost( ) that calculates the total cost of an order. Use the following header:

    private static double totalCost(int number, double cost, double salesTaxRate)

    Number is the number of items (the quantity), cost is the unit cost (the cost of a single item), and salesTax is the sales tax rate. You should select a reasonable value for the unit cost (e.g., $10.00). You should select a reasonable value for the sales tax rate (e.g., 7%). Use your totalCost( ) method to calculate the total cost of the order.
    Last edited by CTimpsonS; 08-30-2015 at 02:02 AM.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Starting a New Project

    about code tags
    See; BB Code List - Java Programming Forum - Learn Java Programming

    Do you have any specific java programming questions?
    You've posted your assignment but I don't see any questions you have about it.

    return the "total cost"
    I expect you mean the program should print it. The return statement is used in a method to return a value.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    benji2505 is offline Senior Member
    Join Date
    Sep 2014
    Location
    MA, USA
    Posts
    399
    Rep Power
    6

    Default Re: Starting a New Project

    I think he/she only has to enter the method that was already spoon-fed in the assignment, calculate quantity x price x (1+taxrate) and print out what the method returns.

  6. #6
    CTimpsonS is offline Member
    Join Date
    Aug 2015
    Posts
    3
    Rep Power
    0

    Default Re: Starting a New Project

    I never wrote coding. How would I go about writing the code... what entries are needed... where in the programming would the new string be placed? In the "private static String getStringInput..." part of the main string or can it appear outside the man?

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Starting a New Project

    How would I go about writing the code
    Before trying to write any code, you need to decide what the code is supposed to do and what detailed steps it needs to take to do it.
    Can you make a list of the steps the program needs to take to compute the total cost?

    Please edit your post and wrap the code in code tags.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. New to Java, Starting a Project
    By Castles in forum New To Java
    Replies: 3
    Last Post: 01-10-2013, 08:50 PM
  2. Starting out
    By Coltraine12 in forum New To Java
    Replies: 2
    Last Post: 09-24-2012, 04:03 PM
  3. Just starting out...Project Idea
    By seguhi in forum Forum Lobby
    Replies: 1
    Last Post: 06-08-2012, 10:20 AM
  4. im starting a project soon but want some tips/help
    By ychen42 in forum New To Java
    Replies: 1
    Last Post: 11-12-2010, 01:17 AM
  5. just starting
    By specbailey in forum New To Java
    Replies: 23
    Last Post: 08-13-2007, 11:25 PM

Posting Permissions

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