473,418 Members | 4,816 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,418 software developers and data experts.

" '.class' expected

I am getting .class expected at debugging for line 16 "sale = input.nextDouble[ ]

Expand|Select|Wrap|Line Numbers
  1. import java.util.Scanner; // program uses class Scanner
  2.  
  3. public class SalesCommission
  4. {
  5.     public static void main( String args[] )
  6.     {
  7.         // create Scanner for input from command window
  8.         Scanner input = new Scanner( System.in );
  9.  
  10.         double sale[] = { 200-299,300-399, 400-499, 500-599, 600-699, 700-799, 800-899, 900-999, 1000-9999 };
  11.  
  12.         System.out.println( "Enter gross sales amount: " ); //prompt  user for input
  13.         sale = input.nextDouble[];
  14.  
  15.         // find commission for individual salary range
  16.         for ( int counter = 0; counter < sale.length; counter++ );
  17.         {
  18.             // output salary range
  19.             if ( sale == 1000 )
  20.                 System.out.print( "%3f-%3f: ",
  21.                 sale[8] = sale[8] * .09 + 200 );
  22.             else
  23.                 System.out.print( "%3f-%3f: ",
  24.                 sale[8] = sale[8] + 1 );
  25.  
  26.             System.out.printf( "%s%8s\n", "Sales", "Salary" );
  27.         } // end for
  28.    } // end main
  29. } // end class SalesCommission 
May 5 '10 #1
5 3250
jkmyoung
2,057 Expert 2GB
Use () instead of []
May 5 '10 #2
Tried ( ) originally and again; got error for that line and additional errors.

c:\Jassign>javac SalesCommission.java
SalesCommission.java:16: incompatible types
found : double
required: double[]
sale = input.nextDouble();
^
SalesCommission.java:22: incomparable types: double[] and int
if ( sale == 1000 )
^
SalesCommission.java:23: cannot find symbol
symbol : method print(java.lang.String,double)
location: class java.io.PrintStream
System.out.print( "%3f-%3f: ",
^
SalesCommission.java:26: cannot find symbol
symbol : method print(java.lang.String,double)
location: class java.io.PrintStream
System.out.print( "%3f-%3f: ",
^
May 5 '10 #3
jkmyoung
2,057 Expert 2GB
oh wait. You're misunderstanding the array
{ 200-299,300-399, 400-499, 500-599, 600-699, 700-799, 800-899, 900-999, 1000-9999 };
gives you an array
{ -99, -99, -99, -99, -99, -99, -99, -99, -8999}
as it treats - as minus or subtract.


You need a secondary double variable to set the output to.
I would set your array to be the lower limits, eg
{ 200,300, 400, 500, 600, 700, 800, 900, 1000};

Your comparison method will have to change as well.
May 5 '10 #4
Unfortunately, our assignment calls for 200-299, 300-399, etc. I have since tried something that will list the salaries, if I remove " sale = input.nextInt ". However, I cannot enter salaries and complete the other requirements of calculating bonuses. Thanks anyway!
May 6 '10 #5
jkmyoung
2,057 Expert 2GB
You can't store ranges in a double array. Either find a class that stores ranges and lets you compare them easily, or use a different loop to find where within the range it fits.

eg:
if sale >= 1000
On second thought, make it an int array:
int[] saleRange = { 200,300, 400, 500, 600, 700, 800, 900, 1000, 10000};
The range of the i'th element is
saleRange[i-1] to (saleRange[i]-1)
May 6 '10 #6

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

Similar topics

2
by: Chuck Martin | last post by:
I am having a most frustrating problem that references, web searches, and other resources are no help so far in solving. Basically, I'm trying to design a pop-up window to be called with a funciton...
3
by: rdi | last post by:
The import statements weren't copy/pasted, but everything INSIDE the class WAS copy pasted from the help file. Starting with the myMail.From line and going down to the SmtpMail.Send line, EVERY line...
3
by: Jon | last post by:
I'm learning about datatables. When using the example provided by MS in the ..NET Framework Class Library for DATATABLE (see below) I get an error on line 3 that says "Type expected". Is something...
14
by: Geoff Jones | last post by:
Hi I'm trying to use a class that I've written in a form. Unfortunately, when I write something like: Public x As New myClass I get the compile time error: "Type Expected". Indeed, the...
45
by: Gregory Petrosyan | last post by:
1) From 2.4.2 documentation: There are two new valid (semantic) forms for the raise statement: raise Class, instance raise instance 2) In python: >>> raise NameError Traceback (most recent...
38
by: looping | last post by:
For Python developers around. >From Python 2.5 doc: The list of base classes in a class definition can now be empty. As an example, this is now legal: class C(): pass nice but why this...
16
by: Steve Chapel | last post by:
When I load the page <https://bugzilla.mozilla.org/attachment.cgi?id=237739with Internet Explorer 7 RC 1, I get the error "Object Expected" at line 174. When I click on the button, I also get the...
1
by: TJ | last post by:
Hello all, I'm having a weird error. I'm getting error CS1513 on Line 36. It appears when I comment out this line, it compiles just fine but doesn't do what I want, which is run the code in the...
10
RMWChaos
by: RMWChaos | last post by:
WinVista/IE7 I am getting some weird errors only in IE7, but not in FF2.0.0.8 or NN9. It even happens on this website when I click "Sign In". The error is: "A Runtime Error has occurred."...
4
by: krinz10 | last post by:
Hi, I am doing an apartment rentals program but i need to bubble sort the array of a user defined class customerDetails (this entails all the details of the customer) However, when i am calling that...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.