[hotjoe.com] HotJoe Java Help Forums
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Visit java.com
Missing post? - see this post about spam for more information.
Messages posted by: carly
Forum Index » Profile for carly » Messages posted by carly
Author Message
by the way these error messages arent clear to me! i'm new to java and havent a clue what im doing
right
this is my code
import java.util.*;
public class JobCollection
{
private ArrayList jobs = new ArrayList();
private ArrayList tempJobs = new ArrayList();
Job j = new Job();
Scanner kybd = new Scanner (System.in);

public void addJob (Job theJob){jobs.add(theJob);}

public void findJob (int jobNo)
{
for (Iterator i = jobs.iterator(); i.hasNext()
{
Job currentJob = (Job) i.next();
}
}

public void getUnpaidJobs()
{
Iterator iter;
ArrayList temp = new ArrayList();
while(iter.hasNext()){j.paid = false;}
{
iter.next() = tempJobs;
tempJobs.add(tempJobs);
System.out.print(tempJobs);
}
}

public void getPaidJobs()
{
Iterator iter;
ArrayList tempJobs = new ArrayList();
while(iter.hasNext()){j.paid = true;}
{
tempJobs = iter.next();
tempJobs.add(tempJobs);
System.out.print(tempJobs);
}
}

public void getTotalPaymentsForUnpaidJobs()
{
Iterator iter;
double total;
while(iter.hasNext())
{
if(iter.hasNext(true).Job.getPaid = false)
{
tempJobs = iter.hasNext();
total += j.getCost();
System.out.println("Total cost for unpaid jobs is: " + total);
}
}
}

public void getTotalCostOfMaterialsForUnpaidJobs()
{
Iterator iter;
int total;
while(iter.hasNext())
{
if(iter.hasNext(true).Job.getPaid = false)
{
tempJobs = iter.hasNext();
total += j.getMaterialsCost();
System.out.println("Total cost of materials for unpaid jobs is: " + total);
}
}
}

public void getTotalRevenue()
{
Iterator iter;
double tempTotalCost;
double totalMaterialsCost;
double tempMaterialsCost;
double total;
while(iter.hasNext())
{
if(iter.hasNext(true).j.getPaid = false)
{
tempJobs = iter.hasNext();
totalMaterialsCost += j.getMaterialsCost();
tempTotalCost += j.getCost;
total = tempTotalCost - totalMaterialsCost;
System.out.println("Total revenue is: " + total);
}
}
}
}


and these are the errors that come up
Iv looked on google and iv tried everything i can think of but i GENUINELY am completely lost as to why it wont work!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!



JobCollection.java:25: unexpected type
required: variable
found : value
iter.next() = tempJobs;
^
JobCollection.java:37: incompatible types
found : java.lang.Object
required: java.util.ArrayList
tempJobs = iter.next();
^
JobCollection.java:49: hasNext() in java.util.Iterator cannot be applied to (boo
lean)
if(iter.hasNext(true).Job.getPaid = false)
^
JobCollection.java:51: incompatible types
found : boolean
required: java.util.ArrayList
tempJobs = iter.hasNext();
^
JobCollection.java:52: cannot find symbol
symbol : method getCost()
location: class Job
total += j.getCost();
^
JobCollection.java:52: inconvertible types
found : <nulltype>
required: double
total += j.getCost();
^
JobCollection.java:64: hasNext() in java.util.Iterator cannot be applied to (boo
lean)
if(iter.hasNext(true).Job.getPaid = false)
^
JobCollection.java:66: incompatible types
found : boolean
required: java.util.ArrayList
tempJobs = iter.hasNext();
^
JobCollection.java:82: hasNext() in java.util.Iterator cannot be applied to (boo
lean)
if(iter.hasNext(true).j.getPaid = false)
^
JobCollection.java:84: incompatible types
found : boolean
required: java.util.ArrayList
tempJobs = iter.hasNext();
^
JobCollection.java:86: cannot find symbol
symbol : variable getCost
location: class Job
tempTotalCost += j.getCost;
^
Note: JobCollection.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
11 errors

cheers for your help iv got it all sorted thanks
hi Sorry for posting loads at the moment its just my deadline is getting dangerously close to the hand in date and iv still got a fat lot of errors

import java.util.*;
public class JobCollection
{
private ArrayList jobs = new ArrayList();
public ArrayList tempJobs = new ArrayList();
Job j = new Job();

public void addJob (Job theJob){jobs.add(theJob);}

public void findJob (int jobNo)
{
for (Iterator i = jobs.iterator(); i.hasNext()
{
Job currentJob = (Job) i.next();
}
}

public void getUnpaidJobs()
{
Iterator iter;
ArrayList temp = new ArrayList();
while(iter.hasNext())
//{paid = false;}
{
iter.next() = tempJob;
tempJobs.add(tempJob);
System.out.print(tempJob);
}
}

public void getPaidJobs()
{
Iterator iter;
ArrayList temp = new ArrayList();
while(iter.hasNext()){paid = true;}
{
tempJob = iter.next();
tempJobs.add(tempJob);
System.out.print(tempJob);
}
}

public void getTotalPaymentsForUnpaidJobs()
{
Iterator iter;
int total;
while(iter.hasNext())
{
if(iter.hasNext(true).Job.getPaid = false)
{
tempjob = iter.hasNext();
total += Job.getCost();
System.out.println("Total cost for unpaid jobs is: " + total);
}
}
}

public void getTotalCostOfMaterialsForUnpaidJobs()
{
Iterator iter;
int total;
while(iter.hasNext())
{
if(iter.hasNext(true).Job.getPaid = false)
{
tempjob = iter.hasNext();
total += Job.getMaterialsCost();
System.out.println("Total cost of materials for unpaid jobs is: " + total);
}
}
}

public void getTotalRevenue()
{
Iterator iter;
int tempTotalCost;
int totalMaterialsCost;
int tempMaterialsCost;
int total;
while(iter.hasNext())
{
if(iter.hasNext(true).Job.getPaid = false)
{
tempjob = iter.hasNext();
totalMaterialsCost += j.getMaterialsCost();
tempTotalCost += getCost();
total = tempTotalCost - totalMaterialsCost;
System.out.println("Total revenue is: " + total);
}
}
}
}

thats the code

these are the errors


JobCollection.java:25: unexpected type
required: variable
found : value
iter.next() = tempJob;
^
JobCollection.java:25: cannot find symbol
symbol : variable tempJob
location: class JobCollection
iter.next() = tempJob;
^
JobCollection.java:26: cannot find symbol
symbol : variable tempJob
location: class JobCollection
tempJobs.add(tempJob);
^
JobCollection.java:27: cannot find symbol
symbol : variable tempJob
location: class JobCollection
System.out.print(tempJob);
^
JobCollection.java:35: cannot find symbol
symbol : variable paid
location: class JobCollection
while(iter.hasNext()){paid = true;}
^
JobCollection.java:37: unexpected type
required: variable
found : value
iter.next() = tempJob;
^
JobCollection.java:37: cannot find symbol
symbol : variable tempJob
location: class JobCollection
iter.next() = tempJob;
^
JobCollection.java:38: cannot find symbol
symbol : variable tempJob
location: class JobCollection
tempJobs.add(tempJob);
^
JobCollection.java:39: cannot find symbol
symbol : variable tempJob
location: class JobCollection
System.out.print(tempJob);
^
JobCollection.java:49: hasNext() in java.util.Iterator cannot be applied to (boo
lean)
if(iter.hasNext(true).Job.getPaid = false)
^
JobCollection.java:51: cannot find symbol
symbol : variable tempjob
location: class JobCollection
tempjob = iter.hasNext();
^
JobCollection.java:52: cannot find symbol
symbol : method getCost()
location: class Job
total += Job.getCost();
^
JobCollection.java:52: inconvertible types
found : <nulltype>
required: int
total += Job.getCost();
^
JobCollection.java:64: hasNext() in java.util.Iterator cannot be applied to (boo
lean)
if(iter.hasNext(true).Job.getPaid = false)
^
JobCollection.java:66: cannot find symbol
symbol : variable tempjob
location: class JobCollection
tempjob = iter.hasNext();
^
JobCollection.java:67: non-static method getMaterialsCost() cannot be referenced
from a static context
total += Job.getMaterialsCost();
^
JobCollection.java:82: hasNext() in java.util.Iterator cannot be applied to (boo
lean)
if(iter.hasNext(true).Job.getPaid = false)
^
JobCollection.java:84: cannot find symbol
symbol : variable tempjob
location: class JobCollection
tempjob = iter.hasNext();
^
JobCollection.java:86: cannot find symbol
symbol : method getCost()
location: class JobCollection
tempTotalCost += getCost();
^
JobCollection.java:86: inconvertible types
found : <nulltype>
required: int
tempTotalCost += getCost();
^
Note: JobCollection.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
20 errors



thank you
public class Job
{
public int jobNo;
public String customer;
public boolean paid;
public double materialsCost;


public Job (){}

public Job (int jobNumber, String customerName, boolean paid, double costOfMaterials)
{jobNo = jobNumber; customer = customerName; paid = false; materialsCost = costOfMaterials;}

public void setJobNo (int jobNumber) {jobNo = jobNumber;}
public void setCustomer (String customerName) {customer = customerName;}
public void setPaid (boolean paid) {paid = false;}
public void setMaterialsCost (double costOfMaterials) {materialsCost = costOfMaterials;}

public int getJobNo () {return jobNo;}
public String getCustomer () {return customer;}
public boolean getPaid () {return paid;}
public double getMaterialsCost () {return materialsCost;}

public void displayDetails()
{
printHeader();
System.out.println("Job Number is :"+ jobNo);
System.out.println("Customer is :"+ customer);
System.out.println("Has the job been paid for? :"+ paid);
System.out.println("Cost of Materials :"+ materialsCost);
}

private void printHeader()
{
System.out.println ("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
System.out.println ("Job Details");
System.out.println ("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
}
}

Job Class
Thank you very much another 2 classes are compiling now!!!

However any idea what the following means -

TestFixedRateJob.java:14: cannot find symbol
symbol : method setLabourCost(double)
location: class Job
aJob.setLabourCost (5.10);
^
TestFixedRateJob.java:27: cannot find symbol
symbol : method getLabourCost()
location: class Job
System.out.println(aJob.getLabourCost( ));
^
2 errors

this is for this code -
public class TestFixedRateJob
{
public static void main(String []args)

{
System.out.println("Testing Fixed Rate Job class");
System.out.println("---------------------------------------");

Job aJob = new Job();
aJob.setJobNo (123);
aJob.setCustomer ("Staffs");
aJob.setPaid (false);
aJob.setMaterialsCost (10.50);
aJob.setLabourCost (5.10);

System.out.println("Testing displayDetails "+"job number 123 customer Staffs paid false materials cost 10.50 labour cost 5.10");
aJob.displayDetails () ;
System.out.println("Testing getJobNo - 123 expected");
System.out.println(aJob.getJobNo( ));
System.out.println("Testing getCustomer - Staffs expected");
System.out.println(aJob.getCustomer( ));
System.out.println("Testing getPaid - false expected");
System.out.println(aJob.getPaid( ));
System.out.println("Testing getMaterialsCost - 10.50 expected");
System.out.println(aJob.getMaterialsCost( ));
System.out.println("Testing getLabourCost - 5.10 expected");
System.out.println(aJob.getLabourCost( ));
}
}

I really appreciate this!
ok Iv sorted out the ;'s now iv got this -

HourlyPaid.java:18: missing return statement
}
^
1 error

any ideas - its from the code i first posted by the way
ok iv changed a few things and now i get
2 errors

HourlyPaid.java:10: ';' expected
ratePerHour = rate;
^
HourlyPaid.java:29: ';' expected
super.displayDetails();
^
2 errors

i dont get this as both of these hav ;'s at the end!?
any ideas?
hi Im having trouble compiling a load of things can anyone tell me why -

public class HourlyPaid extends Job
{
private double ratePerHour;
private int hoursWorked;
private double totalCost;

public HourlyPaid (int jobNumber, String customerName, boolean paid, double costOfMaterials, double rate, int hours);
{
super (jobNumber, customerName, paid, costOfMaterials);
ratePerHour = rate;
hoursWorked = hours;
}

public double calulateTotalCost();{
double cost = ratePerHour * hoursWorked;
double totalCost = cost + materialsCost;
}

public void setRatePerHour (double rate) {ratePerHour = rate;}
public void setHoursWorked (int hours) {hoursWorked = hours;}
public double getRatePerHour(){return ratePerHour;}
public int getHoursWorked(){return hoursWorked;}
public double getCost() {return totalCost;}

public void displayHourlyPaidDetails()
{
printHeader();
super.displayDetails();
System.out.println("The rate per hour is :"+ ratePerHour);
System.out.println("The number of hours worked :" + hoursWorked);
}

private void printHeader()
{
System.out.println ("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
System.out.println ("Hourly Paid Job Details");
System.out.println ("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
}
}

the errors say

HourlyPaid.java:7: missing method body, or declare abstract
public HourlyPaid (int jobNumber, String customerName, boolean paid, dou
ble costOfMaterials, double rate, int hours);
^
HourlyPaid.java:9: call to super must be first statement in constructor
super (jobNumber, customerName, paid, costOfMaterials);
^
HourlyPaid.java:10: cannot find symbol
symbol : variable rate
location: class HourlyPaid
ratePerHour = rate;
^
HourlyPaid.java:11: cannot find symbol
symbol : variable hours
location: class HourlyPaid
hoursWorked = hours;
^
HourlyPaid.java:14: missing method body, or declare abstract
public double calulateTotalCost();{
^
5 errors

theres more if anyone feels they can help any help would be greatly appreciated!
Cheers
its alright its all done and handed in now

thanks to everyone for their help, youve been great
yeah i did

i have just done that and tried it again

it stil doesnt work properly its no 0 any more its 3 (i have to get it to add 3 because part of the assignment states the students only answer 5 of the 8 questions the 3 they dont answer are marked as -1 so adding 3 at the end just cancels them out.
i keep getting an error messgae saying cannot find symbol and its pointing to the second .

System.out.print(i)
yeah i noticed that just after i posted it

i understand what the code does as i wrote it i just cant see why the totals arent being added up and the grades arent being displayed


this code is supposed to allow the user to enter a 5 student IDs and their results and calculate the total and show the grades all the information should be shown in a table. for some reason the first studentID is indented - does anyone know why? also it wont calculate the total or display the grad it just comes up null - anyone know why. iv been staring at it for the past hour
the classpath isnt set
 
Forum Index » Profile for carly » Messages posted by carly
Go to:   
Powered by JForum 2.1.9 © JForum Team
This site run by Scott Dunbar of Xigole Systems. © 2005-2012 - Scott Dunbar
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners
hotjoe.com, xigole.com, and Scott Dunbar have no affiliation with Oracle