My code here is working fine but whenever I run it, it doesn't seem to round up and I don't know what to add and where to add it.
package com.mycompany.billofsale;
public class Billofsale {
public static void main(String[] args) {
double s = 12.49;
double p = 20.00;
double t = 0.13;
double result = s * t;
double result2 = s + result;
double result3 = p - (s + result);
System.out.println("The total is "+s
+ "\n The tax is "+result
+ "\n The total cost with tax is "+result2
+ "\n The change is "+result3);
}
}
You need to use DecimalFormat to format all the numbers that you want to print to the decimals that you want.
Try with this code:
double s = 12.49;
double p = 20.00;
double t = 0.13;
double result = s * t;
double result2 = s + result;
double result3 = p - (s + result);
DecimalFormat format = new DecimalFormat(".00");
format.setRoundingMode(RoundingMode.HALF_UP);
System.out.println("The total is " + s + "\n The tax is " +format.format(result) + "\n The total cost with tax is " + format.format(result2)
+ "\n The change is " + format.format(result3));
Entry level java program that won't compile. Any help at all would be amazing! I really just need a quick review of my basic level code. I get errors for ints, booleans, and doubles. I've tried to rearrange them in multiple ways and i just can not get it to work. Also my Cheesy crust calculation to add it the total. Again super novice but would really enjoy the help!
import java.util.Scanner;
public class programmingassignment1 {
public static void main(String[] args) {
Scanner keyboard = new Scanner( System.in );
int pizzaLength;
int pizzaWidth;
int pizzaShape;
double pizzaDiamiter;
double pizzaToppingPrice = 0.025;
int numberOfPizzaToppings;
double pizzaSauceAndCheese = 0.036;
double pizzaDoughPrice = 0.019;
char doughType;
String dough;
int numberOfPizzas;
double pizzasBeforeTax;
int cheesyCrustInput;
int deliveryWantedInput;
int deliveryCharge;
double doughVolume;
double area;
double crustCost;
int basePrice;
int costOfPizzaWithTax;
//Shape of pizza
System.out.println("What shape of pizza requested?");
System.out.println("Enter (1) for Rectange or (2) Round?");
pizzaShape = keyboard.nextLine().charAt(0);
if(pizzaShape == 1){
System.out.println("What Length?");
pizzaLength = keyboard.nextInt();
System.out.println("What Width?");
pizzaWidth = keyboard.nextInt();
area = pizzaLength * pizzaWidth;
}
else if(pizzaShape == 2){
System.out.println("What is the Diamiter?");
pizzaDiamiter = keyboard.nextInt();
area = Math.PI * (pizzaDiamiter / 2);
}
//Volume
System.out.print("What type of dough do you want? (1)Classic Hand-Tossed, (2)Thin and Crispy, (3)Texas Toast, or (4)Pan. (enter 1,2,3, or 4.");
doughType = keyboard.nextLine().charAt(0);
if (doughType == 1) {
dough = "Classic Hand-Tossed";
doughVolume = area * .25;
}
else if (doughType == 2) {
dough = "Thin and Crispy";
doughVolume = area * .1;
}
else if (doughType == 3) {
dough = "Texas Toast";
doughVolume = area * .9;
}
else if (doughType == 4) {
dough = "Pan";
doughVolume = area * .5;
}
//Cheesey crust
if(doughType == 2){
}
else{
System.out.println("Would you like cheesy crust? (1) for yes (2) for no");
cheesyCrustInput = keyboard.nextInt();
if(cheesyCrustInput == 1){
crustCost = area * .02;
String Crust = "";
}
else{
String Crust = "NO";
}
}
//Toppings
System.out.print("Enter the number of toppings:");
numberOfPizzaToppings = keyboard.nextInt();
if(numberOfPizzaToppings == 0){
String toppings = "no";
}
else{
int toppings = numberOfPizzaToppings;
}
//Base price
basePrice = area (pizzaSauceAndCheese + (pizzaToppingPrice * numberOfPizzaToppings) + (pizzaDoughPrice * doughVolume));
//how many pizzas
System.out.print("Enter the number of pizzas being ordered:");
numberOfPizzas = keyboard.nextInt();
pizzasBeforeTax = basePrice * numberOfPizzas;
//tax
costOfPizzaWithTax = pizzasBeforeTax ( 1 + 0.07);
//delivery fee
System.out.print("Would you like delivery? (1) for yes, (2) for no.");
deliveryWantedInput = keyboard.nextInt();
if(deliveryWantedInput == 1){
String deliveryOutput = numberOfPizzas + "deliverd";
if(costOfPizzaWithTax < 10){
deliveryCharge = 3;
}
if( 10 < costOfPizzaWithTax && costOfPizzaWithTax < 20 ){
deliveryCharge = 2;
}
if(20 < costOfPizzaWithTax && costOfPizzaWithTax < 30){
deliveryCharge = 1;
}
if(costOfPizzaWithTax > 30){
deliveryCharge = 0;
}
}
else{
String deliveryOutput = "no delivery";
}
//display total
total = costOfPizzaWithTax + deliveryCharge;
System.out.println("Total Due: $" + df.format(total));
if(pizzaShape = 1){
System.out.print("User requested: Rectangular, " + pizzaWidth + "X" + pizzaLength + ", " + dough + toppings + "topping(s)"
+ Crust + "cheesy crust," + deliveryOutput + " - Program Output:");
System.out.println("Details for - Rectangular Pizza (" + pizzaWidth + "\" X " + pizzaLength + "\"):");
System.out.println( "Area: " + area );
System.out.println( "Volume:" + doughVolume);
System.out.println( "Base price: $" + basePrice);
System.out.println( "With Cheesy: $");
System.out.println( "Multi Total: $" + pizzasBeforeTax);
System.out.println( "With Tax: $" + costOfPizzaWithTax);
System.out.println( "And Delivery: $" + total);
}
else{
System.out.print("User requested: Circular, " + pizzaDiamiter + "\", " + dough + toppings + "topping(s)"
+ Crust + "cheesy crust," + deliveryOutput + " - Program Output:");
System.out.println( "Area: " + area );
System.out.println( "Volume:" + doughVolume);
System.out.println( "Base price: $" + basePrice);
System.out.println( "With Cheesy: $");
System.out.println( "Multi Total: $" + pizzasBeforeTax);
System.out.println( "With Tax: $" + costOfPizzaWithTax);
System.out.println( "And Delivery: $" + total);
}
}
}
Fixed content follows below!
import java.util.Scanner;
public class programmingassignment1 {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
final double PIZZA_TOPPING_PRICE = 0.025;
final double PIZZA_SAUCE_AND_CHEESE = 0.036;
final double PIZZA_DOUGH_PRICE = 0.019;
double numberOfPizzaToppings;
double crustCost;
double basePrice;
double radiusOfPizza;
double sizeOfPizzaCrust;
double pizzasBeforeTax;
double pizzaLength = 1;
double pizzaWidth = 1;
double pizzaShape = 1;
double pizzaDiamiter = 0;
double doughType = 1;
double numberOfPizzas = 0;
double cheesyCrustInput = 0;
double deliveryWantedInput = 0;
double deliveryCharge = 0;
double doughVolume = 1;
double area = 1;
double costOfPizzaWithTax = 1;
double total = 1;
double toppings = 1;
String dough = "";
String crust = "";
String deliveryOutput;
String cheesyOutput = "";
// Shape of pizza
System.out.println("What shape of pizza requested?");
System.out.println("Enter (1) for Rectangle or (2) Round:");
pizzaShape = keyboard.nextDouble();
if (pizzaShape == 1) {
System.out.println("What Length?");
pizzaLength = keyboard.nextDouble();
System.out.println("What Width?");
pizzaWidth = keyboard.nextDouble();
area = pizzaLength * pizzaWidth;
} else if (pizzaShape == 2) {
System.out.println("What is the Diamiter?");
pizzaDiamiter = keyboard.nextDouble();
radiusOfPizza = pizzaDiamiter / 2;
area = Math.PI * radiusOfPizza * radiusOfPizza;
}
// Volume
System.out.print("What type of dough do you want? (1)Classic Hand Tossed,"
+ " (2)Thin and Crispy, (3)Texas Toast, or (4)Pan. \n(Enter 1,2,3, or 4.)");
doughType = keyboard.nextDouble();
if (doughType == 1) {
dough = "Classic Hand Tossed";
doughVolume = area * .25;
} else if (doughType == 2) {
dough = "Thin and Crispy";
doughVolume = area * .1;
} else if (doughType == 3) {
dough = "Texas Toast";
doughVolume = area * .9;
} else if (doughType == 4) {
dough = "Pan";
doughVolume = area * .5;
}
// Toppings
System.out.print("Enter the number of toppings:");
numberOfPizzaToppings = keyboard.nextDouble();
toppings = numberOfPizzaToppings;
// Base price
basePrice = area * (PIZZA_SAUCE_AND_CHEESE + PIZZA_TOPPING_PRICE * numberOfPizzaToppings)
+ PIZZA_DOUGH_PRICE * doughVolume;
// Cheesey crust
if (doughType == 2) {
cheesyOutput = " no cheesy crust";
crustCost = basePrice;
} else {
System.out.println("Would you like cheesy crust? (1) for yes (2) for no.");
cheesyCrustInput = keyboard.nextDouble();
if (cheesyCrustInput == 1 && pizzaShape == 2) {
sizeOfPizzaCrust = 2 * Math.PI * (pizzaDiamiter / 2);
crustCost = (sizeOfPizzaCrust * .02) + basePrice;
crust = "";
cheesyOutput = " cheesy crust";
} else if (cheesyCrustInput == 1 && pizzaShape == 1) {
sizeOfPizzaCrust = 2 * (pizzaLength + pizzaWidth);
crustCost = (sizeOfPizzaCrust * .02) + basePrice;
crust = "";
cheesyOutput = " cheesy crust";
} else {
crust = " NO cheesy crust";
crustCost = basePrice;
}
}
// how many pizzas
System.out.print("Enter the number of pizzas being ordered:");
numberOfPizzas = keyboard.nextDouble();
pizzasBeforeTax = crustCost * numberOfPizzas;
// tax
costOfPizzaWithTax = pizzasBeforeTax * (1 + 0.07);
// delivery fee
System.out.print("Would you like delivery? (1) for yes, (2) for no.");
deliveryWantedInput = keyboard.nextDouble();
if (deliveryWantedInput == 1) {
deliveryOutput = (int) numberOfPizzas + " pizza delivered";
if (costOfPizzaWithTax < 10) {
deliveryCharge = 3;
} else if (10 < costOfPizzaWithTax && costOfPizzaWithTax < 20) {
deliveryCharge = 2;
} else if (20 < costOfPizzaWithTax && costOfPizzaWithTax < 30) {
deliveryCharge = 1;
} else if (costOfPizzaWithTax > 30) {
deliveryCharge = 0;
}
} else {
deliveryOutput = "no delivery";
deliveryCharge = 0;
}
// display total
total = costOfPizzaWithTax + deliveryCharge;
if (pizzaShape == 1) {
System.out.print("User requested: Rectangular, " + (int) pizzaLength + "X"
+ (int) pizzaWidth + ", " + dough
+ ", " + (int) toppings + " topping(s)," + crust + cheesyOutput + ", "
+ deliveryOutput + " - Program Output:");
System.out.println("\nDetails for - Rectangular Pizza (" + pizzaLength + "\" X "
+ pizzaWidth + "\"):");
System.out.printf("Area: %.3f\n", area);
System.out.printf("Volume: %.3f\n", doughVolume);
System.out.printf("Base price: $%.2f", basePrice);
System.out.printf("\nWith Cheesy: $%.2f", crustCost);
System.out.printf("\nMulti Total: $%.2f", pizzasBeforeTax);
System.out.printf("\nWith Tax: $%.2f", costOfPizzaWithTax);
System.out.printf("\nAnd Delivery: $%.2f", total);
}
else {
System.out.print("User requested: Circular, " + (int) pizzaDiamiter + "\", "
+ dough + ", " + (int) toppings + " topping(s)," + crust + cheesyOutput
+ ", " + deliveryOutput + " - Program Output:");
System.out.println("\nDetails for - Round Pizza (" + pizzaDiamiter + "\" diameter):");
System.out.printf("Area: %.3f\n", area);
System.out.printf("Volume: %.3f\n", doughVolume);
System.out.printf("Base price: $%.2f", basePrice);
System.out.printf("\nWith Cheesy: $%.2f", crustCost);
System.out.printf("\nMulti Total: $%.2f", pizzasBeforeTax);
System.out.printf("\nWith Tax: $%.2f", costOfPizzaWithTax);
System.out.printf("\nAnd Delivery: $%.2f", total);
}
}
}
Your problem is related to scopes:
if ( condition ) {
String topping = "topping";
}
System.out.println(topping);
Will not compile. (Your code is a bit more broad, but still)
The problem here is that topping is a local variable in the if-block, once the if-block is terminated, the variable doesn't exist anymore.
You need to fix it to something like:
String topping = "default";
if ( condition ) {
topping = "topping";
}
System.out.println(topping);
Here is the error free code you need. You just need to create the methods and write your logic in it.
import java.util.Scanner;
public class pizzas {
public static void main(String[] args) {
Scanner keyboard = new Scanner( System.in );
int pizzaLength = 0;
int pizzaWidth = 0;
int pizzaShape;
double pizzaDiamiter = 0;
double pizzaToppingPrice = 0.025;
int numberOfPizzaToppings;
double pizzaSauceAndCheese = 0.036;
double pizzaDoughPrice = 0.019;
char doughType;
String dough = null;
int numberOfPizzas;
double pizzasBeforeTax;
int cheesyCrustInput;
int deliveryWantedInput;
int deliveryCharge = 0;
double doughVolume = 0;
double area = 0;
double crustCost;
int basePrice;
int costOfPizzaWithTax;
//Shape of pizza
System.out.println("What shape of pizza requested?");
System.out.println("Enter (1) for Rectange or (2) Round?");
pizzaShape = keyboard.nextLine().charAt(0);
if(pizzaShape == 1){
System.out.println("What Length?");
pizzaLength = keyboard.nextInt();
System.out.println("What Width?");
pizzaWidth = keyboard.nextInt();
area = pizzaLength * pizzaWidth;
}
else if(pizzaShape == 2){
System.out.println("What is the Diamiter?");
pizzaDiamiter = keyboard.nextInt();
area = Math.PI * (pizzaDiamiter / 2);
}
//Volume
System.out.print("What type of dough do you want? (1)Classic Hand-Tossed, (2)Thin and Crispy, (3)Texas Toast, or (4)Pan. (enter 1,2,3, or 4.");
doughType = keyboard.nextLine().charAt(0);
String Crust = "";
String deliveryOutput="";
if (doughType == 1) {
dough = "Classic Hand-Tossed";
doughVolume = area * .25;
}
else if (doughType == 2) {
dough = "Thin and Crispy";
doughVolume = area * .1;
}
else if (doughType == 3) {
dough = "Texas Toast";
doughVolume = area * .9;
}
else if (doughType == 4) {
dough = "Pan";
doughVolume = area * .5;
}
//Cheesey crust
if(doughType == 2){
}
else{
System.out.println("Would you like cheesy crust? (1) for yes (2) for no");
cheesyCrustInput = keyboard.nextInt();
if(cheesyCrustInput == 1){
crustCost = area * .02;
Crust = "";
}
else{
Crust = "NO";
}
}
//Toppings
System.out.print("Enter the number of toppings:");
numberOfPizzaToppings = keyboard.nextInt();
int toppings;
if(numberOfPizzaToppings == 0){
toppings = 0;
}
else{
toppings = numberOfPizzaToppings;
}
//Base price
basePrice = area (pizzaSauceAndCheese + (pizzaToppingPrice * numberOfPizzaToppings) + (pizzaDoughPrice * doughVolume));
//how many pizzas
System.out.print("Enter the number of pizzas being ordered:");
numberOfPizzas = keyboard.nextInt();
pizzasBeforeTax = basePrice * numberOfPizzas;
//tax
costOfPizzaWithTax = pizzasBeforeTax ( 1 + 0.07);
//delivery fee
System.out.print("Would you like delivery? (1) for yes, (2) for no.");
deliveryWantedInput = keyboard.nextInt();
if(deliveryWantedInput == 1){
deliveryOutput = numberOfPizzas + "deliverd";
if(costOfPizzaWithTax < 10){
deliveryCharge = 3;
}
if( 10 < costOfPizzaWithTax && costOfPizzaWithTax < 20 ){
deliveryCharge = 2;
}
if(20 < costOfPizzaWithTax && costOfPizzaWithTax < 30){
deliveryCharge = 1;
}
if(costOfPizzaWithTax > 30){
deliveryCharge = 0;
}
}
else{
deliveryOutput = "no delivery";
}
//display total
int total = costOfPizzaWithTax + deliveryCharge;
//System.out.println("Total Due: $" + df.format(total));
if(pizzaShape == 1){
System.out.print("User requested: Rectangular, " + pizzaWidth + "X"
+ pizzaLength + ", " + dough + toppings + "topping(s)"
+ Crust + "cheesy crust," + deliveryOutput + " - Program Output:");
System.out.println("Details for - Rectangular Pizza (" + pizzaWidth + "\" X " + pizzaLength + "\"):");
System.out.println( "Area: " + area );
System.out.println( "Volume:" + doughVolume);
System.out.println( "Base price: $" + basePrice);
System.out.println( "With Cheesy: $");
System.out.println( "Multi Total: $" + pizzasBeforeTax);
System.out.println( "With Tax: $" + costOfPizzaWithTax);
System.out.println( "And Delivery: $" + total);
}
else{
System.out.print("User requested: Circular, " + pizzaDiamiter + "\", " + dough + toppings + "topping(s)"
+ Crust + "cheesy crust," + deliveryOutput + " - Program Output:");
System.out.println( "Area: " + area );
System.out.println( "Volume:" + doughVolume);
System.out.println( "Base price: $" + basePrice);
System.out.println( "With Cheesy: $");
System.out.println( "Multi Total: $" + pizzasBeforeTax);
System.out.println( "With Tax: $" + costOfPizzaWithTax);
System.out.println( "And Delivery: $" + total);
}
}
Methods:
private static int pizzasBeforeTax(double d) {
// TODO Auto-generated method stub
return 0;
}
private static int area(double d) {
// TODO Auto-generated method stub
return 0;
}
Issues in your code:
1. You have not initialized the variables you have used.
2. You have declared the variables in if and else clause. When you are planning to re-use the variables, never initialize them inside as their scope is restricted to the block.
3. Also, you have used the same variable name toppings as String and int .
I am a beginner and not tried the following program which is giving me repeated output.. I have to end the program manually in eclipse. Not able to figure out the problem. Please advice. Any other tips are welcome.
import java.util.Scanner;
public class Sales_Amount {
public static void main(String[] args) {
final double Base_Salary = 25000;
double Commission = 0;
double Total_Salary;
double X;
double Y;
Scanner input = new Scanner(System. in );
System.out.print("Enter Sales Amount: ");
double Sales = input.nextDouble();
while (Commission < 25001) {
if (Sales <= 5000); {
Total_Salary = Base_Salary + (0.08 * Sales);
System.out.print(" Total Salary for " + Sales + "worth of Sales is: " + Total_Salary);
}
if (Sales > 5000 && Sales < 10001); {
X = Sales - 5000;
Total_Salary = Base_Salary + (0.08 * 5000) + (0.10 * X);
System.out.print(" Total Salary for " + Sales + "worth of Sales is: " + Total_Salary);
}
if (Sales > 10001); {
Y = Sales - 10000;
Total_Salary = Base_Salary + (.08 * 5000) + (.10 * 10000) + (.12 * Y);
System.out.print(" Total Salary for " + Sales + "worth of Sales is: " + Total_Salary);
}
}
}
}
Add commission++ before the end of the loop.
I must convert inches into miles. Then calculate the remaining feet after I calculate the miles. Then calculate the remaining inches after that. The output I'm getting is 19 miles, 19 feet, 7 inches when it should be 19 miles, 2560 feet, 7 inches.
import java.util.Scanner;
/**
* #author abc
* #version 1-28-2014
*/
public class DistanceConverter {
public static void main(String[] args) {
Scanner userInput = new Scanner(System.in);
int numOfInches;
System.out.print("Enter the raw measurement in inches: ");
numOfInches = userInput.nextInt();
if (numOfInches < 0) {
System.out.println("Measurement must be non-negative!");
}
int feet = numOfInches / 12;
int miles = feet / 5280;
int remainingFeet = miles % feet;
int remainingInches = numOfInches % 12;
if (numOfInches > 0) {
System.out.println("\n\nMeasurement by combined miles, feet, inches:");
System.out.println("\tmiles: " + miles);
System.out.println("\tfeet: " + remainingFeet);
System.out.println("\tinches " + remainingInches);
System.out.println("\n\n" + numOfInches + " inches = " + miles
+ " miles, " + remainingFeet + " feet, " + remainingInches + " inches");
}
}
}
Try something like this:
if( numOfInches > 0 ) {
int inchesInFeet = 12;
int feetsInMile = 5280;
int inchesInMile = feetsInMile * inchesInFeet;
int miles = numOfInches / inchesInMile;
int remainingInches = numOfInches % inchesInMile;
int feet = remainingInches / inchesInFeet;
remainingInches = remainingInches % inchesInFeet;
System.out.println( "\n\nMeasurement by combined miles, feet, inches:" );
System.out.println( "\tmiles: " + miles );
System.out.println( "\tfeet: " + feet );
System.out.println( "\tinches " + remainingInches );
System.out.println( "\n\n" + numOfInches + " inches = " + miles
+ " miles, " + feet + " feet, " + remainingInches + " inches" );
}
The entirety of the code can be found at the bottom of this post, but the only part that really concerns me is,
for(zed = 0; zed<photoes.size(); zed++) {
totesPrice += photoes<zed>.getCost();
totesSize += photoes<zed>.getMegabytes();
totesSpeed = photoes<zed>.getSpeed();
}
Ideally the totesPrice, totesSize, and totesSpeed would be the sum of the get methods for the objects stored in the photoes list array.
// Import classes for class
import java.util.Arrays;
import java.util.List;
import javax.swing.*;
import java.awt.event.*;
import java.text.DecimalFormat;
import java.util.ArrayList;
public class DigitalMain
{
public static void main(String args[])
{
String cont = "Y";
String heightString,width,bitpsString = "";
String widthString = "";
int zed;
double bitps,pHS,pWS = 0.0;
double totesSpeed = 0.0;
double totesPrice = 0.0;
double totesSize = 0.0;
DecimalFormat wholeDigits = new DecimalFormat("0");
DecimalFormat dec = new DecimalFormat("0.00");
List<DigitalPhoto> photoes = new ArrayList<DigitalPhoto>();
do
{
DigitalPhoto photo = new DigitalPhoto();
heightString = JOptionPane.showInputDialog("Please enter height");
pHS = Double.parseDouble(heightString);
photo.setHeight(pHS);
widthString = JOptionPane.showInputDialog("Please enter width");
pWS = Double.parseDouble(widthString);
photo.setWidth(pWS);
JOptionPane.showMessageDialog(null, "Height: " + photo.getHeight() + "\nWidth: " + photo.getWidth() + "\nResolution: " + photo.getResolution() + " DPI\nCompression Ratio: " + photo.getCompression() + "\nRequired Storage: " + dec.format(photo.getKilo()) + " Kilobytes.\nPrice of Scanned Photo: $" + dec.format(photo.getCost()) + " dollars.");
do
{
bitpsString = JOptionPane.showInputDialog("Please enter your internet connection speed in BITS not BYTES please.");
bitps = Double.parseDouble(bitpsString);
} while (bitps < 0 && bitps > 99999999);
photo.setSpeed(bitps);
for(zed = 0; zed<photoes.size(); zed++) {
totesPrice += photoes<zed>.getCost();
totesSize += photoes<zed>.getMegabytes();
totesSpeed = photoes<zed>.getSpeed();
}
cont = JOptionPane.showInputDialog("\nType \'Y\' to try again or anything but \'Y\' to use values.");
photoes.add(photo);
} while (cont.equalsIgnoreCase("Y"));
double seconds = transferTime(totesSize, totesSpeed);
double minutes = seconds / 60;
double realsec = seconds % 60;
JOptionPane.showMessageDialog(null, "You will be paying: " + totesPrice + "\nRequired Storage is: " + totesSize + "Required time for transfer is: " + wholeDigits.format(minutes) + " minutes, and " + wholeDigits.format(realsec) + " seconds.");
}
public static double transferTime(double totalStorage, double netSpeed) {
double bits, seconds;
bits = (totalStorage * 8);
seconds = (bits / netSpeed);
return seconds;
};
}
I think u have to your generics.. for:each
u can try this ...
for (DigitalPhoto digitalPhoto : photoes) {
totesPrice += digitalPhoto.getCost();
totesSize += digitalPhoto.getMegabytes();
totesSpeed = digitalPhoto.getSpeed();
}
for(zed = 0; zed<photoes.size(); zed++)
{
totesPrice += photoes.get(zed).getCost();
totesSize += photoes.get(zed).getMegabytes();
totesSpeed = photoes.get(zed).getSpeed();
}
Try this.
You could use an Iterator instead :
Iterator it = photoes.iterator();
while(it.hasNext())
{
DigitalPhoto temp = it.next();
totesPrice += temp.getCost();
totesSize += temp.getMegabytes();
totesSpeed = temp.getSpeed();
}