In the test program, you will need to convert the Strings for quantity and price to numeric types. To do this, you could use the Integer.parseInt() method and the Double.parseDouble() methods. I'm not sure what he means by that. I attempted it in my program but I get these errors
Exception in thread "main" java.lang.Error: Unresolved compilation problems: number cannot be resolved to a variable description cannot be resolved to a variable quantity cannot be resolved to a variable price cannot be resolved to a variable Duplicate local variable quantity Duplicate local variable price Syntax error on token "myInvoice", delete this token The method getinvoiceAmount() is undefined for the type String
at InvoiceTest.main(InvoiceTest.java:7)
Code:
public class Invoice { private String number; //Instance variables private String description;//Instance variables private int quantity;//Instance variables private double price;//Instance variables
I post the code I'm developing for a tetris-based characters. The problem I have is that I can't print the piece within the board. I haven't any error.
Class Piezas
Java Code:
public class Piezas {
public Piezas() {} //atributos private int i; private int j; private char m[][]; private int formaPieza;
The operator < is undefined for the argument type(s) java.util.ArrayList<FacebookUser>, java.util.ArrayList<FacebookUser>
For this:
class FriendsComparator implements Comparator<FacebookUser> { @Override public int compare(FacebookUser o1, FacebookUser o2) { int returnValue = 0; if (o1.friends < o2.friends) returnValue = -1; [Code] ....
Same as for the second if condition. How can I fix this exactly? What I'm doing is trying to sort Facebook users by the most to least amount of friends.
i want to make a piece of software that enables me to Press a key on my keyboard and then it will play a Sound. But i Want to be able to do it when i'm playing.Can code The Sound an Keys
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?
I've got my clear button to work on most of the stuff I want, however I cant figure out how to fix the price to stop adding up. e.g. hit a button image with a price of 599.99, hit the clear button to empty, select price of 599.99 again then it display 1199.98.
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.
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);
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
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");
The Program prompts the user to enter the number of products in the product catalog. The program should then prompt the user for the name and the price of each product in the product catalog. Once all of the products have been entered, the program should output the product information (name and price) of the most expensive product in the catalog. Your solution to keep track of the product with the highest price.
import java.util.Scanner; public class ProductTester { private static final String price = null; public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.print("Enter the number of Products: "); int count = console.nextInt();
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. :(
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;
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();
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
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
Basically the class is supposed to have a static variable that keeps track of the number of companies (numberOfCompanies) that have been created and a static method that returns the value of this variable. I need to have a constructor and a method to addEmployee, a method to printCompany, and a toString method. The addEmployee method will check that there is only 1 salesperson, 2 designers, and 4 manufacturing persons at a time and will check that there are no more than 7 employees of the company.
The addEmployee method will return a String indicating what the error is (i.e. "There is already a sales person in this company") or a null if the employee was added. If attempting to name a third company, an error message will be shown. what i have so far but my print company mmethod returns null company class :in which i am obliged to use inputdialog because it says that it cannot return void when i use the showmeassage diaolog.
company class:
import java.util.ArrayList; import javax.swing.JOptionPane; public class Company { private ArrayList<Employees> list ; private static int numberOfCompanies;
[Code] ....
error message when print button is clicked:
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: JOptionPane: parentComponent does not have a valid parent at javax.swing.JOptionPane.createInternalFrame(Unknown Source) at javax.swing.JOptionPane.showInternalOptionDialog(Unknown Source) at javax.swing.JOptionPane.showInternalMessageDialog(Unknown Source)
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?
public static void main() { int i; // counter createDeck(); // this is a function call // Show the cards in the deck System.out.println("The deck is as follows:"); for (i=0 ; i < CARDS_IN_DECK ; i++)
[code]....
It is now printing out the value of myDeck[5] but I need to print out first 5 values.
public class Lab12 { public static int SumRow(int [][] a){ int row, column, sum=0; for (row=0;row<2;row++ ) { sum=0; for (column=0;column<2;column++) { sum=sum+a[row][column];
[Code]...
my output is
The sum of row 1 is: 3 The sum of coloumn 0 is: 5 The sum of coloumn 1 is: 5 The max of row 0 is: 4 The max of row 1 is: 2