Results 1 to 5 of 5
  1. #1
    _inase is offline Member
    Join Date
    Jan 2011
    Posts
    13
    Rep Power
    0

    Default personalizing instructions

    I'm writing a program that prompts the user to enter information about their car in order to calculate various costs.
    I already prompted the user to enter their name, but I also want the other prompts to include their name so it's more personalized.
    I tried different ways but I get an error, please help!:eek:
    Here's a piece of my program...
    For example I want it to say "(name) enter the make and model of your car"

    import java.util.*;
    public class CarCosts
    {
    public static void main(String[] args)
    {
    Scanner keys=new Scanner(System.in);
    System.out.println("Welcome, this program will determine the cost of owning and operating your car for the number of years you are in college.");
    {

    System.out.println("Please enter your name: ");
    String firstName = keys.next();
    System.out.println("Enter the make and model of your car: ");
    String carModel = keys.next();
    System.out.println("Enter the price of your car: ");
    double initialPrice = keys.nextDouble();

  2. #2
    _inase is offline Member
    Join Date
    Jan 2011
    Posts
    13
    Rep Power
    0

    Default

    nevermind I got it!

  3. #3
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    but I get an error
    Wow, that's terrible. What do you want us to do about it? Perhaps if you told us what error you got we might be able to help.
    For example I want it to say "(name) enter the make and model of your car"
    Well you did store the users name in a variable so it is just a matter of adding the variable into the print statement. Try a see if you can do it yourself without me showing. Remember if you get an error post your code and the EXACT error message.

  4. #4
    _inase is offline Member
    Join Date
    Jan 2011
    Posts
    13
    Rep Power
    0

    Default

    I figured it out already. Thanks

  5. #5
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    Well done but remember in future we do not read minds and statements like "I got an error" or "my code doesn't work" provides zero information.

Similar Threads

  1. Print image and send additional PCL instructions.
    By bronai in forum Advanced Java
    Replies: 1
    Last Post: 05-16-2011, 07:18 PM
  2. Replies: 1
    Last Post: 03-21-2009, 05:46 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
  •