The Artima Developer Community
Sponsored Link

Java Answers Forum
New user to Java. Need some help with my program

6 replies on 1 page. Most recent reply: Sep 29, 2006 8:19 AM by Monique Ellis

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 6 replies on 1 page
Monique Ellis

Posts: 5
Nickname: moeski
Registered: Sep, 2006

New user to Java. Need some help with my program Posted: Sep 28, 2006 1:59 PM
Reply to this message Reply
Advertisement
I Have to write a java program for a local store which try to make a profit by marks up the prices of items by a certain percentages. The program which reads the orginial price of the item sold, the percentage of amrked up price, sales tax rate. The program then outputs the orginial price of the item. The marked up percentage of the item, the store selling price of the item. The sale tax rate, the sale tax, and the final price of the item ( the final price of the item is the selling price plus sales tax.
So far I have the following:

import java.util.*;
public class project1

{
original_price = console.nextdouble();


public static void main ( String [] args)

{

//declares variables
double orginal_price;
double item_sold;
double marked_up_price;
double percentage;
double sales_tax;
final final_price

System.out.print ("Enter orginal price: ");
System.out.flush();
oringal price = console.nextInt();
System.out.println();

System.out.print("Enter item sold: ");
System.out.flush();
item_sold = console.nextInt();
System.out.println();

Sytem.out.print("Enter marked up price: ");
System.out.flush();
marked_up_price = console.nextInt();
System.out.println();

System.out.print("Enter percentage: ");
System.out.flush();
percentage= console.nextInt();
System.out.println();

Sytem.out.print("Enter sale tax: ");
System.out.flush();
sale_tax = console.nextInt();
System.out.println();

System.out.print("Enter final price: ");
System.out.flush();
final_price = console.nextInt();
System.out.println();

System.out.println();
System.out.prin tln ("Enter The original price of the item");

System.out.println();
System.out.println ("Marked up percentage of the item");

System.out.println();
System.out.println ("The selling price=$ + selling price");

System.out.println();
System.out.println ("Sales Tax Rate = sales tax");

System.out.println();
System.out.println ("The Final price");

System.out.println();
System.out.println ("The Final price of item + selling price + sales tax$");



}
}

now I'm down to 2 errors,but I'm not sure on calculations


Monique Ellis

Posts: 5
Nickname: moeski
Registered: Sep, 2006

Re: New user to Java. Need some help with my program Posted: Sep 28, 2006 3:48 PM
Reply to this message Reply
Ok..I've taken a different route.. Can someone help me with the same program, but I've made some revisions: import java.util.*;
public class project1

{
original_price = console.nextdouble();


public static void main ( String [] args)

{

//declares variables
double orginal_price;
double marked_up_pct;
double sales_tax_pct;

System.out.print ("Enter orginal price: ");
System.out.flush();
oringal price = console.nextInt();
System.out.println();

System.out.print("Marked up Percentage: ");
System.out.flush();
marked_up_pct = console.nextInt();
System.out.println();

Sytem.out.print("Enter Sales Tax Percentage: ");
System.out.flush();
sales_tax_pct = console.nextInt();
System.out.println();


System.out.println();
System.out.println ("Enter The original price of the item");

System.out.println();
System.out.println ("Marked up percentage of the item");

System.out.println();
System.out.println ("The selling price=$ + selling price");

System.out.println();
System.out.println ("The Final price");


marked_up_pct = orginal_price * marked_up_pct;
selling_price = orginal_price + marked_up_amt;
sales_amt = selling_price * sales_tax_pct;
Final_Price = selling_price + sales_amt;



}
}

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: New user to Java. Need some help with my program Posted: Sep 28, 2006 11:17 PM
Reply to this message Reply
Your code is illegible please re-format with indentitions and re-post it.

Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: New user to Java. Need some help with my program Posted: Sep 28, 2006 11:45 PM
Reply to this message Reply
First of all, when posting code, use the java tags as described in the "Formatting Your Post" section (on the right of the input field). That makes reading it a lot less annoing.

Here are some of your errors:

1. You once wrote "original price" instead of "original_price"
2. What is "console"? You didn't declare or initialize it.
3. sales_amt, selling_price, Final_price (don't use capitals for a variable) are not declared either.

Once you fixed this, you just have to print out the results.

Monique Ellis

Posts: 5
Nickname: moeski
Registered: Sep, 2006

Re: New user to Java. Need some help with my program Posted: Sep 29, 2006 8:02 AM
Reply to this message Reply
Ok..this is all new to me so I'll try
Thanks

Monique Ellis

Posts: 5
Nickname: moeski
Registered: Sep, 2006

Re: New user to Java. Need some help with my program Posted: Sep 29, 2006 8:02 AM
Reply to this message Reply
Ok..thanks! I'll fix and repost

Monique Ellis

Posts: 5
Nickname: moeski
Registered: Sep, 2006

Re: New user to Java. Need some help with my program Posted: Sep 29, 2006 8:19 AM
Reply to this message Reply
I was told by the instructor to use console.. I don't have my book with me to look it up to or to find out what it's purpose codes are... I will do that tonight when I get home..sorry -(

java.util.*;
public class project1

{
original_price = console.nextdouble();


public static void main ( String [] args)

{

//declares variables
double orginal_price;
double marked_up_pct;
double sales_tax_pct;

System.out.print ("Enter orginal price: ");
System.out.flush();
oringal_price = console.nextInt();
System.out.println();

System.out.print("Marked up Percentage: ");
System.out.flush();
marked_up_pct = console.nextInt();
System.out.println();

Sytem.out.print("Enter Sales Tax Percentage: ");
System.out.flush();
sales_tax_pct = console.nextInt();
System.out.println();


System.out.println();
System.out.pri ntln ("Enter The original price of the item");

System.out.println();
System.out.println ("Marked up percentage of the item");

System.out.println();
System.out.println ("The selling price=$ + selling price");

System.out.println();
System.out.println ("The Final price");


marked_up_pct = orginal_price * marked_up_pct;
selling_price = orginal_price + marked_up_amt;
sales_amt = selling_price * sales_tax_pct;
Final_Price = selling_price + sales_amt;



}
}

Flat View: This topic has 6 replies on 1 page
Topic: Draw the expression tree Previous Topic   Next Topic Topic: system.gc

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use