473,473 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

It won't compile

21 New Member
Here is the error:

01C.java
Program01C.java:9: <identifier> expected
import static java.lang.Math.*;
^
Program01C.java:9: '.' expected
import static java.lang.Math.*;
^
2 errors

Here is the code:

Expand|Select|Wrap|Line Numbers
  1. //Robert Burns
  2. //Feb. 5, 2009
  3. //paradox6996@gmail.com
  4. //Program01B-Calculates total average of test scores
  5.  
  6. import java.util.Scanner;
  7.  
  8. //Math class so I can truncate doubles to get nice looking decimals
  9. import static java.lang.Math.*;
  10.  
  11. public class Program01C {
  12.  
  13.    public static void main(String[] args) {
  14.  
  15.     double purchase, totalTax, salesTax, countyTax, total, totalSalestax, totalCountytax;
  16.  
  17.     salesTax = 0.04;
  18.     countyTax = 0.02;
  19.  
  20.  
  21.    Scanner keyboard = new Scanner(System.in);
  22.    System.out.print("Enter the Amount of Purchase:");
  23.    purchase = keyboard.nextDouble();
  24.  
  25.    totalSalestax = (purchase * salesTax);
  26.    totalCountytax = (purchase * countyTax);
  27.    totalTax = (salesTax + countyTax);
  28.    total = (((totalTax) * purchase) + purchase);
  29.  
  30.    System.out.printf("Sales Tax: " + totalSalestax + "\nCounty Tax: " + totalCountytax + "\nTotal Sales Tax: " + totalTax + "\nPurchase Amount: " + purchase + "\nTotal Amount: %.2f", total, Math.ceil(total));
I've gotten it to compile before so idk why it isn't working now. Any ideas?
Feb 11 '09 #1
3 1551
JosAH
11,448 Recognized Expert MVP
You don't have to explicitly import anything from the java.lang package; it has been done implicitly for you.

kind regards,

Jos

ps. what is your compiler version? btw, the forum software swallows leading spaces so the caret in the error message doesn't show up at the correct location. Better make the error messages a code block.
Feb 11 '09 #2
r035198x
13,262 MVP
Yep, the version must be the problem here. Static imports are only here with us after version 1.5.
P.S If you do a static import of
Expand|Select|Wrap|Line Numbers
  1.  import static java.lang.Math.*;
, then you don't need to say Math.ceil in the code. Just say ceil. Otherwise there is no point in having that static import in there at all.
Feb 11 '09 #3
paradox6996
21 New Member
I figured it out last night I have Gentoo linux and somehow blackdown JDK was selected as the compiler and it doesn't support static imports. I selected JDK 1.6 and all worked fine. Thanx for the replies though.

Paradox(>")>
Feb 11 '09 #4

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

Similar topics

2
by: Gary Redmond | last post by:
I am writing a program to store stuff to xml using the storeToXML method but I can;t get it to compile here it is; any ideas? import java.io.*; import java.util.*;
47
by: Will Stuyvesant | last post by:
Hello all, So Zope still lives, yay. Well, I like that they use Python. <rant> What amazed me is they write that they "added types to the variables and hope that it will be added to the...
19
by: Christopher | last post by:
I am getting a parse error from g++ pointing at my catch line and can't figure out whats wrong with this code: #include "BigPosInt.h" #include <iostream> #include <new> #include <assert.h> ...
4
by: Vince | last post by:
I'm getting this message when I try and run a .net web app in the development system: CS0016: Could not write to output file 'c#:\windows nt\Microsoft..net framework\v1.1.4322\Temporary ASP.NET...
3
by: Dave C | last post by:
I've written the following code that won't compile, trimmed down to just the pertinent stuff: --- WindowClass.hxx ---------------------------------------------------- #include <set> class...
4
by: David Killian Woods | last post by:
I just installed VC++.NET and haven't had much luck. It just won't compile anything that isn't stored on a local hard drive. Local projects are fine (well, other than my stupid mistakes) and...
10
by: Martin Jørgensen | last post by:
Hi, I got this piece of code, but I won't compile: #include <iostream> using namespace std; //////////////////////////////////////////////////////////////// struct link ...
4
by: Susan Rice | last post by:
I'm new to using CString. Why won't the following compile? I'm using Microsoft Visual C++ 6.0 Line 37 which it complains about is the function: 37 CString ConvertFile(char *szFileName) I...
2
by: APA | last post by:
The problem is that there is no reference to the DLL anywhere in the solution. I have other developers running this identical solution with no problems but on my machine it won't compile if I don't...
6
by: bc1891 | last post by:
#include <stdio.h> #include <stdlib.h> def RecursiveFact(n): if(n>1): return n*RecursiveFact(n-1) else: return 1 fact = RecursiveFact(31)
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.