473,320 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

cannot find symbol error...?

i encountered this problem, yet as much as i tried, could not find the source to this error.
Expand|Select|Wrap|Line Numbers
  1. import java.util.*;
  2. import java.io.*;
  3.  
  4. public class billing {
  5.  
  6.     public static void main(String args[]) 
  7.         {
  8.         Scanner kbReader = new Scanner (System.in);
  9.         System.out.println("How many jerseys? ");
  10.         int jersey = kbReader.nextInt();
  11.  
  12.  
  13.         System.out.println("How many trousers? ");
  14.         int trouser = kbReader.nextInt();
  15.  
  16.         if (jersey>=50)
  17.         {
  18.  
  19.         if (trouser>=50)
  20.     {
  21.             if (jersey>=trouser)
  22.             {int leftoverJ = jersey - trouser;}
  23.             {double costj = leftoverJ*64.95;}
  24.             {double costUniform = trouser*79.95;}
  25.     }    
  26.             else 
  27.               {int leftoverT = trouser - jersey;}
  28.                {double costT= leftoverT*42.5;}
  29.                {double costUniform = jersey*79.95;}
  30.         }        
  31.  
  32.  
  33.     else 
  34.     System.out.println("Total cost: " + (64.95*jersey + 42.5*trouser));
  35.  
  36.     } 
  37.  
  38. }
Nov 25 '09 #1
2 2589
Here's the error message:

------------------Configuration: <Default>--------------------
C:\Users\Hoang\Documents\billing.java:30: cannot find symbol
symbol : variable leftoverJ
location: class billing
{double costj = leftoverJ*64.95;}
^
C:\Users\Hoang\Documents\billing.java:35: cannot find symbol
symbol : variable leftoverT
location: class billing
{double costT= leftoverT*42.5;}
^
2 errors
Nov 25 '09 #2
pbrockway2
151 Expert 100+
Try this:

Expand|Select|Wrap|Line Numbers
  1. if (jersey>=50)
  2. {
  3.     if (trouser>=50)
  4.     {
  5.         if (jersey>=trouser)
  6.         {
  7.             int leftoverJ = jersey - trouser;
  8.             double costj = leftoverJ*64.95;
  9.             double costUniform = trouser*79.95;
  10.         }
  11.         else
  12.         {
  13.             int leftoverT = trouser - jersey;
  14.             double costT= leftoverT*42.5;
  15.             double costUniform = jersey*79.95;
  16.         }
  17.     }
  18. }
  19. else
  20.     System.out.println("Total cost: " + (64.95*jersey + 42.5*trouser));
  21. }
  22.  
Use the braces to group together the statements that refer to a given condition (that is either the if part, or the else part). Do this even if there is only one such statement like the last else part in your code. But do not go wrapping everything in braces as this will end up being very confusing at best.
Nov 25 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Tony Johansson | last post by:
Hello! I get compile error when compiling using the command javac from the command terminal window(CMD). I have just two classes which are called HelloWorld.java and Slask.java. I have both...
15
by: Bjorn Jensen | last post by:
Hi! An beginner question: Pleas help me with this (-: Error (the arrow points on the s in sqrt) ===== tal.java:6: cannot find symbol symbol : method sqrt(int) location: class tal...
1
by: vsp15584 | last post by:
Hii..i use the coding as below :- import java.applet.applet; import java.awt.*; import com.sun.j3d.utils.applet.mainframe; import com.sun.j3d.utils.universe.*; import...
1
by: Shiva48 | last post by:
Thanks to Gannon11 and ro351988- Moderator. I give below the complete Java file and pls help me to rectify the errors. package com.wrox.proj2ee.ch10.app; import java.io.*; import...
1
by: jank | last post by:
hi, I wrote sending mass email program in java. If i try to compile using ant compiler, i am getting this error. c:\mail\src\com\mail\action\SendMail.java:125: cannot find symbol ...
4
by: jingchua | last post by:
Hi, can anyone help out here???? I have the below error after compling the file. Any idea what is wrong in the declaration that was done in the above code??? Appreciate any help on shedding some...
2
by: karinmorena | last post by:
I'm having 4 errors, I'm very new at this and I would appreciate your input. The error I get is: Week5MortgageGUI.java:151:cannot find symbol symbol: method allInterest(double,double,double)...
10
by: CodeNoob | last post by:
please help been working on a project got it down to 5 errors from 100 now i have no idea what to do. Errors: init: deps-jar: Created dir: C:\Users\Tommy\Desktop\build\classes Compiling 306...
3
by: Sindhu Rani | last post by:
i hav created 3 classes in 3 different files. am gettin an error durin compilation. wat shud i do??? C:\s\source>javac -d ..\classes devtestdrive.java devtestdrive.java:5: cannot resolve symbol...
2
suzee_q00
by: suzee_q00 | last post by:
Compiler seems to be hanging up on "new" but I know it isn't but I can't seem to figure out what it is that it doesn't like. Been chasing my tail for the last couple of days. Any help would be...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.