Note that there are some explanatory texts on larger screens.

plurals
  1. POgetting an error cannot find symbol
    primarykey
    data
    text
    <p>i am writing a program that calculates the amount saved for someone bying a car. i have two classes the first one called called Carsavings2 compiles fine however the second class Crsavings3 seems to keep coming up with an error which says can not find symbol on the line where i am trying to instantiate the other class. i am new to java so its probably sumthin daft but i can not figure it out. Any help would be great here is how the code looks for both cladsses</p> <pre><code>import java.util.Scanner; import java.lang.Math; public class Carsavings3 { public static void main(String[] args) { double equalAmounts, l, amount, numberOfYears, carCost; Carsavings2 Carsavings2Object = new Carsavings2(equalAmounts, l, amount, numberOfYears, carCost); Scanner read = new Scanner(System.in); do { //This will print out a request for the user System.out.println("Please input the cost of the car, a real number 0 or greater\n"); //This will ensure the input value will remain between 0 and above carCost = read.nextDouble(); } while (carCost &lt;=1); do { //This will print out a request for the user System.out.println("Please input number of years, an integer between 1 and 10\n"); //This will ensure the input value will remain between 1 and 10 numberOfYears = read.nextDouble();} while ((numberOfYears&lt;1)||(numberOfYears&gt;10)); } } </code></pre> <p>/<em>the errors i am getting are as follows</em>/</p> <pre><code>C:\Users\User\Documents\imran&gt;javac Carsavings3.java Carsavings3.java:22: error: cannot find symbol carCost = read.nextdouble(); } while (carCost &lt;=1); ^ symbol: method nextdouble() location: variable read of type Scanner Carsavings3.java:28: error: cannot find symbol numberOfYears = read.nextdouble();} while ((numberOfYears&lt;1)||(n umberOfYears&gt;10)); ^ symbol: method nextdouble() location: variable read of type Scanner Carsavings3.java:30: error: cannot find symbol Carsavings2 Carsavings2Object = new Carsavings2(equalAmounts, l, amount, numberOfYears, carCost); ^ symbol: variable equalAmounts location: class Carsavings3 Carsavings3.java:30: error: cannot find symbol Carsavings2 Carsavings2Object = new Carsavings2(equalAmounts, l, amount, numberOfYears, carCost); ^ symbol: variable l location: class Carsavings3 Carsavings3.java:30: error: cannot find symbol Carsavings2 Carsavings2Object = new Carsavings2(equalAmounts, l, amount, numberOfYears, carCost); ^ symbol: variable amount location: class Carsavings3 Carsavings3.java:30: error: cannot find symbol Carsavings2 Carsavings2Object = new Carsavings2(equalAmounts, l, amount, numberOfYears, carCost); ^ symbol: variable numberOfYears location: class Carsavings3 Carsavings3.java:30: error: cannot find symbol Carsavings2 Carsavings2Object = new Carsavings2(equalAmounts, l, amount, numberOfYears, carCost); ^ symbol: variable carCost location: class Carsavings3 7 errors </code></pre> <p><em>the following class compiles fine with no errors</em></p> <pre><code>import java.util.Scanner; import java.lang.Math; public class Carsavings2 { //variables private double carCost; private double numberOfYears; //constructor public Carsavings2(double equalAmounts,double l,double amount, numberOfYears,double carCost){ } public void equalAmounts(double numberOfYears){ System.out.println("Equal Amount Method: \n\n"); int l; double amount; for(l=0;l&lt;=numberOfYears;l++){ amount = (carCost/numberOfYears); System.out.println("Year "+numberOfYears+" saved this year: " +amount+ "total saved: " +amount+ "remaining: " +carCost); } System.out.print("");} </code></pre> <p>} *any help would be greatly appreciated. i have been trying to figure it out for almost 4 hours now an just not getting any closer</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload