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


ADVERTISEMENT

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

Difference From One Equation Is Being Added To Total Of Another

Jan 21, 2015

I am writing a program for finding the profit made after paying the broker. here is my code, I am wondering why Java

Code: paidBroker = commission + commissionAfterSale; mh_sh_highlight_all('java');

is being added to

Java Code: noProfit = profit - paidBroker; mh_sh_highlight_all('java');

Here is my full program, you can find these lines of code on lines 64 and 70.

Java Code:

import java.util.Scanner;
public class StockTransaction {
public static void main(String[] args) {
// TODO Auto-generated method stub
//Variable Declaration Section

[Code] ....

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

Client Class - Cannot Get Total Price To Recognize Surcharge

Apr 26, 2015

I am almost finished with my code. The only hangup I am having is that in my client class, I can't get the total price to recognize a surcharge.

This is my output:
-------------------------------------------------
Your order consists of:

coffee, type mocha, size large, cost: $5.8
tea, flavor earl grey, size medium, cost: $3.6

The total cost of your order is: $8.4
----------------------------------------------------
Notice that the total should be $9.4, rather than $8.4. It is odd because I was able to add a surcharge to my coffee(50 cents), and it does in fact recognize it when calculating the price of the coffee. So why won't my totalPrice in the client class recognize it?

Here is my Client class:

public class CoffeeShop {
public static void main(String[] args)
//One coffee
Coffee coffee = new Coffee(16,"mocha");
coffee.set_price_per_oz(coffee.size);

[Code] ....

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

Calculating Total And Average Of Price Of Items - Not Getting Correct Output

Jun 27, 2014

Why is my program not calculating the total and average of the price of the items and not printing it out?

Java Code:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package assignment4;

[code]...

It prints out everything but the total of the items and I dont know why. :(

View Replies View Related

Counting Total Number Of Searches - Calling Price Method

Apr 23, 2015

How would I program a counter that will return the total number of search, failed searches and correct searches. The second thing is how can a return the price of the search methods with out calling for it specifically. Here is my current code.

package stu.paston.program7;
import java.util.Scanner;
public class MainClass
{
public static void main(String[] args)
{
InventoryClass productData= new InventoryClass();

[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

Java Program That Specifies Three One-dimensional Arrays Names Price / Amount And Total

Dec 2, 2014

Recently I have missed a few weeks of my class due to family emergencies. Because of this I have missed very important lectures. My professor has assigned me the following assignment:

Prices Write a Java program that specifies three one-dimensional arrays names price, amount, and total. Each array should be capable of holding 10 elements. Using a loop, input values for the price and amount arrays. The entries in the total array should be the product of the corresponding values in the price and amount arrays. After all the data have been entered, display the following output:

Total Price Amount

==== ==== ======

Under each column heading display the appropriate value.

I know how to display everything using printf, how to create the actual arrays and define the array size, but I am confused on how and what loop to use and how to construct it. This is what I have managed to write up so far:

import java.util.Scanner; // Imports the Scanner class
import java.text.DecimalFormat; // Imports the DecimalFormat class

public class Prices
{
public static void main(String [] args)
{
double[] price = new double[10];
double[] amount = new double[10];
double[] total = new double[10];

// Create a new Scanner object
Scanner keyboard = new Scanner(System.in);
} //End of main method
} // End of public class

View Replies View Related

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 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

Display Text - Methods Involving Loops

May 14, 2014

So I want the method getDisplayText of d to be returned as long as the for loop runs. When I do this I get a compile time error to enter a return statement. I am currently trying to fix it by returning an empty string, yet this doesn't seem the right way to go.

public static String displayMultiple(Displayable d, int count)
{
for(int i = 1; i <= count; i++)
return d.getDisplayText();
return "";
}

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

Display Result Of Two Dice Thrown Five Times And Total Of Those Results

Sep 12, 2014

I need to create a simply application that would display the results of two dice thrown five times and the total of those results. This is shown below in the attached file.

The problem is, I have a do-while loop that loops 6 times. Inside the loop, I have 2 random.nextInt(5) that generate random numbers. But how can I output the total? How can I make a variable equal to the sum of the two random numbers if the two random numbers are located inside a do-while loop?

Attached below is also the code I have thus far.

(Attached below is both files: what it needs to look like, and what it currently looks like)

View Replies View Related

JOptionPane - Display Total Number Of Goals Scored By All Players

May 22, 2014

JOptionPane.showMessageDialog(null,myRoster.totalGoalsScored + " is the total number of goals scored by all the players on the roster");

HOW CAN I CALL THE METHOD totalGoalsScored and display it using JOptionPane

ERROR: CAN NOT FIND SYMBOL

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

Basic GUI Calculator - Display Amount Of Commission And Total Annual Salary In Dollar Format

Apr 28, 2014

So, I am supposed to write a program that calculates the total annual compensation for a salesman using user input for the salary, sales, and commission rate (list of 3 predefined commission rates. have to display in dollar format the amount of commission and total annual salary.

CommCalc class

public class CommCalc
{
//attributes of class, stored data
private double sales;
private double salary;
private double rate;
//and a total field? beware stale data.
//store sales argument from sales field
public void setSales(double sal)

[Code] ....

I know that i have to fix some of the semantics . I have this code that I made earlier, is there an easy way to make it into a GUI interface? Or will I have to go throughthe code lines to add the JOptionPane? And I am a little confused on how to make a list (array) for the commission rate.

View Replies View Related

How To Get Total Number Of Pennies In Dollar Amount For The Output Of Total Pay

Mar 28, 2014

I cannot get the right output for my program. I need to get the total number of pennies in dollar amount for the output of Total Pay. This is my program. The directions are:

Write a program that calculates the amount a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, and continues to double each day. The program should then show the total pay at the end of the period. The output should be displayed in a dollar amount, not the number of pennies. Do not accept a number less than 1 for the number of days worked.

import java.util.Scanner;
import java.text.DecimalFormat;
public class PenniesForPay {
public static void main(String[] args) {
int numDays;

[Code] ....

totalSalary should be total number of pennies / 100....However its not picking up only day 30 of pennies which is 536,870,912 pennies and then dividing it?

View Replies View Related

Populate Array Using Nested Loops With Letter From A Until Y And Display Array To Screen

Nov 15, 2014

We were given a class lab that asks us to write a program that create a multidimensional array ( 5 x 5 ), populates the array using nested loops with letter from A until Y, and displays the array to the screen. and the result should look like this:

A B C D E
F G H I J
K L M N O
P Q R S T
U V W X Y

How to write this program.. I have tried all my best but the results are not coming like this..

View Replies View Related

Manifest Not Added To Jar

Apr 26, 2015

I am creating a .jar for a game I made. I'm not using any dev tools, just a DOS console call to java: %~dp0....javajdkinjar.exe -cfmv TheSwarm.jar manifest.txt *

My manifext.txt contains:

Main-Class: Game

But when I compile the jar, its manifest contains:

Manifest-Version: 1.0
Created-By: 1.7.0_01 (Oracle Corporation)

And I get an error about it not finding the main class. Shouldn't my Main-Class setting be added to the jar? I can manually rename it to .zip and edit the Manifest.MF but that is a huge pain when I'm testing the .jar file and regenerating it often.

View Replies View Related

How Can Items Be Added To List

Feb 13, 2014

I have the following code. how can items be added to that list?

private List<IComponentNode> comp;
interface IAAAView {
  // returns component with given code or null
  IComponentNode findComp(String a);
  // returns component with given renderer or null

[Code] .....

View Replies View Related

Reuse Dynamically Added Controls

Nov 8, 2014

I am trying to create a form where my customer can add some other fields(like: label,textbox), and he need to use that added fields for the next time he open the application...

I would like to know whether it is possible to save dynamically created controls and reuse it again...

View Replies View Related

JSF :: Column Added In ForEach Tag Not Displaying

Nov 4, 2014

I have a ace:dataTable which contains a variable number of columns. For this I use the c:forEach tag. All generated in the c:forEach are not displayed. In the sample, only columnLibelle and columnSum are displayed.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"

[Code] ....

View Replies View Related

Netbeans - How To Remove Added Library

Feb 13, 2014

I'm just a java beginner. I've spent a lot of time installing and configuring software. I'm using Netbeans 7.3 on Windows 7, 64 bit. Recently, I downloaded opencsv from sourceforge.

With no previous experience adding libraries, I read a blog post on adding the library. I think that I then:

Start a new project.

Right click on libraries

Add jar/folder

Gave the temporary path to the .jar file

After, I read the blog post again, and realized I'd missed it. This time I did:

Right click library, Add library, Create library

However, I kept getting a message that the same library already existed. If I do the first process above, I will find the same library.

However, I see no way in Netbeans to remove it. I've deleted the test projects. And started a new one. But the library now exists for all projects it seems.

I've grepped all the files under the Netbean directory, searching for "opencsv", but found nothing. The only things in the Windows registry were locations of files.

How can I delete this library permanently from Netbeans? Short of, uninstall, then reinstall? Is there a way to list all the libraries that Netbeans has?

View Replies View Related







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