1 Replies - 316 Views - Last Post: 05 February 2009 - 08:42 AM Rate Topic: -----

#1 tscott  Icon User is offline

  • D.I.C Regular

Reputation: 2
  • View blog
  • Posts: 370
  • Joined: 30-January 09

Can't figure out this java error

Post icon  Posted 05 February 2009 - 08:34 AM

 import java.util.Scanner;
public class Farmer2
{
  public static void main (String [] args)
  {
	Scanner Keyboard= new Scanner (System.in);
	
	int eggs;
	double cartons, leftovercartons, totalvalue, crates, valueofcrate, valueofleftover;
	
	System.out.print("Enter amount of eggs ");
	eggs= Keyboard.nextInt();
	
	
	  cartons = eggs/12;
	  crates = eggs/12/24;
		leftovercartons = cartons% 24;
		totalvalue = valueofcrate+valueofleftover;
		valueofcrate = 2.25*crates*24;
		valueofleftover = 1.125*leftovercartons;
		
		System.out.println(" The number of cartons filled is " + cartons);
		System.out.println(" The number of crates filled is " + crates);
		System.out.println(" The number of leftover cartons is " + leftovercartons);
		System.out.println(" The total value of eggs is $" +totalvalue);
		System.out.println(" The total value of crates is $" +valueofcrate);
		System.out.println(" The total value of leftover cartons is $" +valueofleftover);
		System.out.println(" The total value is $ " +totalvalue);
  }
}





I'm trying to get the total value of crates and leftover cartons.

This is the error I'm receiving.

2 errors found:
File: C:\Documents and Settings\Tim\Desktop\javaprograms\Farmer2.java [line: 18]
Error: C:\Documents and Settings\Tim\Desktop\javaprograms\Farmer2.java:18: variable valueofcrate might not have been initialized
File: C:\Documents and Settings\Tim\Desktop\javaprograms\Farmer2.java [line: 18]
Error: C:\Documents and Settings\Tim\Desktop\javaprograms\Farmer2.java:18: variable valueofleftover might not have been initialized

Is This A Good Question/Topic? 0
  • +

Replies To: Can't figure out this java error

#2 tscott  Icon User is offline

  • D.I.C Regular

Reputation: 2
  • View blog
  • Posts: 370
  • Joined: 30-January 09

Re: Can't figure out this java error

Posted 05 February 2009 - 08:42 AM

figured it out nevermind
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1