Calculate And Display Price Of Each Object Each Year For 5 Years

Apr 18, 2015

For this program I am calculating the annual costs of 5 office supplies (user input) each with a 5.7% inflation. The user inputs the cost of each object and my program must calculate and display the price of each object each year for 5 years. I already have this part. What I need is how to add the total costs of all 5 supplies per year and display each total cost. Here is the program:

import java.util.Scanner;//Using keyboard to enter data
//Start of Class
public class OfficeSupplyCalculator {
//Start of Method
public static void main(String args[]) {
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter the first item");

[Code] .....

At the moment all I get for the grand total loop is the same number showing up 5 times. I feel like the problem is how I am declaring the grandtotalperyear variable but I'm not sure what is wrong.

View Replies


ADVERTISEMENT

Swing/AWT/SWT :: Sort JTable Data On Year Between A Range Of Years?

Jan 16, 2014

i have a JTable with data that contains a column with Years.

I want to get the user to be able to sort the data between a range of two years.

Example:

a user sets te filter so he/she can view all the data between the years 1990 and 2000.

I am a beginner in Java and don't know how to code such a filter.

I guess it will be something with an if/Else statement or a loop?

View Replies View Related

Calculate Total Price And Display Total In Order Class

Oct 11, 2014

I'm struggling with inheritance in my assignment. The assignment states that I should use the calculatePrice() to calculate the total price and use another method to display the total. The I must overload the calculatePrice() and add a fee in the SpeedOrder() class.

My main class

package useorder;
import javax.swing.*;
public class UseOrder {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Order.display();

[Code] .....

The problem is mainly displaying the TotalPrice field and. I can't display TotalPrice if it's not static but if it's static I can't inherit it to the SpeedOrder class to assign the total in the overloaded calculateprice method. How can I display the total in my order class and use it in my SpeedOrder class?

View Replies View Related

How Does Program Know To Calculate For Only One Year

Mar 26, 2015

how does the program know to calculate for only one year?

public class Interest2 {
public static void main(String[] args) {
double principal; // The value of the investment.
double rate; // The annual interest rate.
double interest; // The interest earned during the year.

[code]....

View Replies View Related

Calculate Price And Quantity With Or Without Discount?

Oct 24, 2014

double price;
String PriceStr;
int quantity;
String QuantityStr;
PriceStr = JOptionPane.showInputDialog("Enter the price: ");
price = Double.parseDouble(PriceStr);
QuantityStr = JOptionPane.showInputDialog("Enter the quantity: ");

[code]....

So i tried to make it allows the user can continue pick the option and calculate the total of every time they select the option, mine is only 2 times.

View Replies View Related

Calculate Quantity / Price And Total Amount

Apr 10, 2015

How to calculate the qty and price and total of the amount in total column.

View Replies View Related

JSP :: Shopping Cart - Calculate Total Price

Sep 21, 2014

I am making a shopping cart web, but some problems I meet about how to calculate the total price

I use ajax in product list web and if I choose one product , it will send the Id that I read from MySql to servlet and use session to save it . and I click the button jump to the cart, the page cart.jsp will read information from session ,and find product information from mysql by id , now my question is where I calculate the total price, servlet or jsp?

View Replies View Related

Calculate Total Price At The End Of Order - Decimal Format

Apr 13, 2015

I have an assignment to create a JFrame pizzaorder and at the end of this order after the totalprice is calculated I need to format the number to ##.## but I keep getting a cannot find symbol error.

Source Code:

import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
public class pizzaorder extends JFrame implements ItemListener, ListSelectionListener
//top section will have centered title telling the name, and under it seperate instructions to choose your pizza and toppings

[Code] ....

View Replies View Related

Create A Program That Calculate Price Of Carpeting For Rectangle Rooms

Apr 23, 2014

I am not getting any syntax errors but the program simply does nothing when I run it.

I literally just get "run: BUILD SUCCESSFUL (total time: 3 seconds)".

So basically, I need to create a program that calculates the price of carpeting for rectangle rooms.(multiply the area of the floor by the price per square foot of the carpet).

-The RoomDimension class should have two fields: one for length and one for width, and a method that returns the area of the room
-The RoomCarpet class that has a RoomDimension object as a field, a field for the cost of carpet per square foot, and a method that returns the total cost of the carpet

Here is what I have:

package roomdimension.java;
public class RoomDimension {

private double length=0;
private double width=0;
private final double area = length * width;

public void RoomDimension(double len, double w)

[Code] ....

View Replies View Related

Create Array / Store 5 Objects And Calculate Total Price - VAT Rate

May 6, 2014

How can I do the work below in Java

In this main class, create 5 objects of the class Menu, as defined in the table below.

Name amount of calories cooking time price per person number of drinks

Fufu and Groundnut Soup 564.65 2515.572
Red Red 345 12 9.980
Rice and Beef Stew 560.4 1512.651
Ga Kenkey and Fish 780 10 10.15 1
Banku and Tilapia 450.4 35 25.17 2

Exercise d
In your main class create an array of length 5, and store the 5 objects (Exercise c) into the array. You can use any name for your array.

From the array, use a loop to: Print the details of all the objects using the method you defined in Exercise b.

Exercise e
Use another loop to:
-Print only the name and cooking time of all the dishes that take less than 30 minutes to cook. Hint: you may use the getter methods for the name and cooking time attributes, and then, print these values (name, cooking time).

Exercise f
Use another loop to :
-Calculate and print the total price of all the objects (in the array).
-Calculate the total price of all the objects with VAT included for each dish (VAT rate is 17.5%).

Submission
-Create a folder with your index number as its name.
-Copy your Java Project folder into the created folder.
-Print a hard copy of your classes.
-Submit both soft copy and hard copy of your project

View Replies View Related

Cumulative Sum - Display Total Price From All Loops Added Together

Feb 27, 2014

In the code below, under calculations, I have x=totalPrice+xXxXxX. Obviously the x's were just place holders, but I wanted to know if there was any way to add something there so the program would tally the totalPrice, store it in the x variable outside the loop, so when the loop ended it would display the total price from all the loops added together where I have System.out.println("TOTAL OF ALL ORDERS: $"+ round.format(x)); at the very end.

Java Code:

import java.util.Scanner;
import java.text.DecimalFormat;
public class ModifyOrderV2TEST
{
public static void main(String [] args)
{
//Rounding
DecimalFormat round = new DecimalFormat("0.00");

[Code] ....

View Replies View Related

Display Properties Of Each Object Instead Of Object Array List Itself?

Mar 23, 2015

If I set a Jlist to contain an array of objects, how can I display properties of each object instead of the object array list itself. Ex:

Instead of:

Person1
Person2
Person3

display values such as each person name within the Jlist:

Mike
Paul
Andrew

View Replies View Related

Calculate And Display Normal / Overtime And Total Pay

Sep 12, 2014

The pay rate is php 35.00 per hour. any hours worked after 40 hours is paid at rate of 2 times the normal hourly rate. Calculate and display the Normal Pay, The overtime pay, and the total pay.

OUTPUT MUST BE:

Sample 1 :

Enter Hours Worked: 40 (Sample)
Normal Pay: 1400 (Sample)
Overtime Pay: 0 (Sample)
Total Pay: 1400 (Sample)

Sample 2 :

Enter Hours Worked: 41 (Sample)
Normal Pay: 1400 (Sample)
Overtime Pay: 70 (Sample)
Total Pay: 1470 (Sample)

Here is my code or something, but i cant finish it.

import java.util.Scanner;
public class Workpay {
public static void main(String[]args) {
Scanner in = new Scanner (System.in);
int hours;
int normalpay = 35;

[Code] .....

View Replies View Related

Calculate And Display Person Body Mass Index

Feb 12, 2015

I have to write a program that calculates and displays a person's body mass index (BMI). The BMI is often used to determine whether a person with sedentary lifestyle is overweight or underweight for his or her height. A person's BMI is calaculated with the following formula:

BMI = Weight X 703/Height^2

where weight is measured in pounds and height is measured in inches. The program should display a message indicating whether the person has optimal weight, is underweight, or is overweight. A sedentary person's weight is considered optimal if his or her BMI is between 18.5 and 25. If the BMI is less than 18.5, the person is considered underweight. If the BMI value is greater than 25, the person is considered overweight.However I can't seem to get rid of these errors:

----jGRASP exec: javac BMI.java
BMI.java:28: error: cannot find symbol
Scanner keyboard = new Scanner(System.in);
^
symbol: class Scanner
location: class BMI
BMI.java:28: error: cannot find symbol

[code]....

View Replies View Related

How To Calculate And Display Win / Loss For Two Different Teams Using Boolean Function And Arrays

Jan 28, 2015

I am still new to Java and have an assignment that I am stuck on. I believe I got the boolean function correct, however I cannot figure out what to write in the main function. I have exhausted searching, and trying different loops, arrays, etc.

View Replies View Related

Calculate Possible Tiles Clicked Unit Can Be Moved On And Display It To Player

May 15, 2014

Alright, so I'm having problems with lines 11 - 55. I'm trying to calculate the possible tiles the clicked unit can be moved on and display it to the player.

The field is a 9 (columns) by 5 (rows) grid. A unit with can move tiles horizontally or vertically based on its movement.

Example: (unit = o; possible tiles = x) (assuming movement of 2).

[ ][ ][ ][ ][x][ ][ ][ ][ ]
[ ][ ][ ][x][x][x][ ][ ][ ]
[ ][ ][x][x][o][x][x][ ][ ]
[ ][ ][ ][x][x][x][][ ][ ]
[ ][ ][ ][ ][x][ ][ ][ ][ ]

I tried to calculate movement by finding out what column the unit is in, subtracting the column it wants to go to, multiplying the difference by *-1 if the difference is less than 0. Then, doing the same with rows and adding the difference of columns to the difference of rows and comparing it to the unit's movement. Unfortunately, with my code, it seems to move in any directions.

@Override
public void mouseClicked(MouseEvent e) {
if (Main.cards.size() > 0) {
mainloop: for (int i = 0; i < Main.cards.size(); i++) {
Card c = (Card) Main.cards.get(i);
int startingColumn = 0;

[Code] ......

View Replies View Related

Calculate Total Amount Paid And Display It - NULL Error

Dec 10, 2014

Exception in thread "main" java.lang.NullPointerException
at ShoeStore.calculateTotal(ShoeStore.java:103)
at ShoeStore.main(ShoeStore.java:88)

This is the error when program is ran. The program is supposed to calculate the total amount paid for all shoes and display it.

import java.util.Scanner;
 public class ShoeStore
{
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
String shoe_Name, nameStore, type;
int size, shoeAmount;
double sellingCost;
 
 [Code] .....

View Replies View Related

Calculate Cost Of Ticket Order And Display Receipt For Customer On Screen

Oct 4, 2014

Write a program that will calculate the cost of a ticket order and display the receipt for the customer on the screen. There are 2 ticket prices: adult, and senior citizen. Adult seats are $4.50 and senior citizen seats are $3.50. If more than 5 senior citizen tickets are purchased, the customer gets an extra 20% off the of the ticket order. If more than 10 regular seats are purchased, the customer gets an additional 10% off the cost of the order. A customer can only place an order for one type of ticket. Output the type of ticket purchased, the number of tickets purchased, the gross cost, the amount of the discount, and the final cost of the order.

I am having errors with incaompatible varriables comparing float with doubles.

public class lab3 {
  static Library myLib;
  public static void main (String [] args) {
  Library myLib = new Library(); //Instance the Library class
int ticketNum; //Number of Tickets

[Code] .....

View Replies View Related

Java GUI - Calculate And Display Total Cost For Certain Automotive Maintenance Services

May 12, 2014

I'm trying to create a GUI application that calculates and displays the total cost for certain automotive maintenance services. The application should contain hree classes: 1) the main class that creates and displays the window; 2) a panel for the routine services and 3) a panel for the non-routine services. 2 and 3 are instantiated in 1. I'm pretty positive the error lies in the NonRoutinePanel class because when I comment it out of the main class the program runs fine. But I can't quite figure out which lines of code or methods are causing the problem.

When I try running the program I get these error messages:

Exception in thread "main" java.lang.NullPointerException
at java.awt.Container.addImpl(Container.java:1040)
at java.awt.Container.add(Container.java:958)
at javax.swing.JFrame.addImpl(JFrame.java:540)
at java.awt.Container.add(Container.java:926)
at JoesAutomotiveGUI.<init>(JoesAutomotiveGUI.java:38)
at JoesAutomotiveGUI.main(JoesAutomotiveGUI.java:111)

Here's my code for the three classes:

import javax.swing.*; // Needed for Swing class
import java.awt.*; // Needed for BorderLayout class
public class RoutineMaintenancePanel extends JPanel
{
public final double oilChange = 26.00;// cost of oil change
public final double lubeJob = 18.00;// cost of lube job

[Code] .....

View Replies View Related

Prompts User To Enter 5 Test Scores And Their Names - Calculate And Display Average

Sep 24, 2014

Using Bluejay. Need code that prompts user to enter 5 test scores and their names. Calculate the average and display.

First initial and last name , 5 test scores, and average

View Replies View Related

Calculating Years Between Two Dates?

Feb 24, 2014

write a program that reads in the year, month, and day of a couple's wedding date and compute thier next wedding anniversary after March 2, 2011.

TThis has to be input in a message dialog box also.

View Replies View Related

How To Return Value (amount) In 10 Years

Mar 14, 2014

Here's the small project... but how can I return the value (amount) in 10 years ? The way I did, the program just doesnt return anything...

import java.util.Scanner;
public class FutureValue
{
public static void main (String []args) {
double amount = 0;
double apr = 0;
System.out.println("How much money would you like to invest?");

[Code] ....

View Replies View Related

Display Object Twice From Same Class

May 2, 2014

I am trying to get an object to display twice from a class in an applet.

Java Code:

if (label == 4) {
game.stop();
timer.start();
result.setText(" You Have Destroyed the World");
marFoundDisplay.setText("Martian: " + String.valueOf(mCount));
jupFoundDisplay.setText("Jupiterian: " + String.valueOf(jCount));
highScoreDisplay.setText("HighScore : " + String.valueOf(HighScore));
j.draw(g, 350, 150);
j.draw(g, 350, 150); mh_sh_highlight_all('java');

Obviously calling it twice doesn't get the desired effect, I'm ultimately trying to get them to be side by side in the middle of the applet, but clearly what I've done won't achieve that.Can you provide me an example that would allow me to display the code below to have the item be displayed twice side by side?

Java Code:

j.draw(g, 350, 150); mh_sh_highlight_all('java');

View Replies View Related

Program That Prompts The User To Enter Loan Amount And Years

Oct 21, 2014

so I had to make a program that prompts the user to enter a loan amount and the years for the loan and I have the conversions and everything my only issue is that when the chart pops up it just looks like a bunch of numbers and its missing the column headers

for example

Interest Rate Monthly Payment Total Payment

import java.util.Scanner; 
public class InterestRate { 
public static void main(String[] args) { 
double monthlypayment = 0; 
double totalpayment = 0; 
Scanner input = new Scanner(System.in);
System.out.println("Enter Loan Amount");

[Code]...

View Replies View Related

Converting Days Into Weeks / Months / Years - Invalid Method Declaration

May 29, 2014

import java.util.Scanner;
public class days
{ public EnumTest ()
{ this.day = weeks/months/years}
final int daysInMonth = 30; //constants
final int monthsInYear = 12;
final int daysInWeek = 7;
public void convert()

[Code] ....

after compiling it shows invalid method declaration ; return type required.

View Replies View Related

Find The First Day Of Any Year?

Jan 25, 2014

write a program in java to enter a year and find out the first day of that year

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved