473,783 Members | 2,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Java measurement program

6 New Member
I need some help with a Measurement Program I Wrote.....I have this code as the main workings of my program:
Expand|Select|Wrap|Line Numbers
  1. import java.util.*;
  2.  
  3. public class Measurement{
  4. {
  5.   static Scanner console = new Scanner(System.in)
  6.   public static void main(String[] args);
  7.   double feet, inches, feetTotal, inchTotal, centTotal;
  8.   boolean done;
  9.   String str;
  10.  
  11.   ConvExc checkForZero = new ConvExc();
  12.  
  13.   public void printScreenFeet() throws InputMismatchException {
  14.     done = false;
  15.     do{
  16.       try
  17.       {
  18.         System.out.println("Enter Feet Measurement:");
  19.         double feet;
  20.         System.out.flush();
  21.         feet = console.nextDouble();
  22.         while (checkForZero.enterZeroExc(feet)) {
  23.           System.out.println("Please Enter a Number Greater then Zero!");
  24.           System.out.println("Enter Feet Measurement:");
  25.           System.out.flush();
  26.           feet = console.nextDouble();
  27.         }
  28.         done = true;
  29.       }
  30.       catch (InputMismatchException imeRef){
  31.         str = console.next();
  32.         System.out.println("Error: Please enter a new number value");
  33.         System.out.println();
  34.       }
  35.     }while (!done);
  36.   }
  37.  
  38.   public void printScreenInch() throws InputMismatchException {
  39.     done = false;
  40.     do{
  41.       try{
  42.         System.out.println("Enter Inches Measurement:");
  43.         double inches;
  44.         System.out.flush();
  45.         inches = console.nextDouble();
  46.         while (checkForZero.enterZeroExc(inches)) {
  47.           System.out.println("Please Enter a Number Greater then Zero!");
  48.           System.out.println("Enter Inches Measurement:");
  49.           System.out.flush();
  50.           inches = console.nextDouble();
  51.         }
  52.         done = true;
  53.       }
  54.       catch (InputMismatchException imeRef){
  55.         str = console.next();
  56.         System.out.println("Error: Please enter a new number value");
  57.         System.out.println();
  58.       }
  59.     }while (!done);
  60.   } 
  61.  
  62.   feetTotal = feet*30.48;
  63.   inchTotal = inches*2.54;
  64.   centTotal = feetTotal+inchTotal;
  65.   System.out.println(feetTotal + " cm in " + feet + " feet");
  66.   System.out.println(inchTotal + " cm in " + inches + " inches");
  67.  
  68.   System.out.println("Total cm = "+centTotal);
  69.  
  70.   }
  71.  
  72. }

.....when i compile i am getting 2 errors the errors i'm getting are:

Measurement.jav a:5: illegal start of expression
static Scanner console = new Scanner(System. in)
^
Measurement.jav a:13: illegal start of expression
public void printScreenFeet () throws InputMismatchEx ception {;

Does anyone know how to fix these errors? I've got no idea and I need some help BADLY!!! Please Help!!!

THANKS!!


The Supporting Classes i have are the Main2 class:
Expand|Select|Wrap|Line Numbers
  1. public class Main2 {
  2.  
  3.  
  4.     public static void main(String[] args) {
  5.  
  6.         Conversion display = new Conversion();
  7.         display.printScreenFeet();
  8.         display.printScreenInch();
  9.         display.printConversion();
  10.  
  11.     }
  12.  
  13. }
  14.  
  15.  
  16. and the ConvExc Class:
  17.  
  18. import java.util.*;
  19.  
  20. public class ConvExc {
  21.  
  22.  
  23.         public boolean enterZeroExc(double num){
  24.  
  25.             if (num<0) {
  26.             return true;
  27.             }
  28.             else {
  29.                 return false;
  30.             }
  31.  
  32.  
  33.         }

.......PLEASE HELP!! THANK YOU!!
Dec 17 '09 #1
3 2612
pbrockway2
151 Recognized Expert New Member
Expand|Select|Wrap|Line Numbers
  1. static Scanner console = new Scanner(System.in)
You have a missing semicolon at the end of this line.
Dec 17 '09 #2
pbrockway2
151 Recognized Expert New Member
In PM:

I changed and added the semicolon and it still doesn't compile. Its still throwing up 3 errors in the measurement.jav a file. I don't know what is wrong with them and was wondering if you might know what the errors would be??
I think it's best for forum discussions to be held in the forum. That way everyone is able to contribute what they can.

I would suggest that you describe the problem: ie post code and compiler messages that are causing problems. There's no need to post a whole lot of stuff. Start with the supporting classes and get them right. (They are not in the code you posted originally.) And then make sure they are all present (Conversion is missing in what you posted).

Work just one small step at a time and deal with compiler errors as they arise.
Dec 17 '09 #3
Frinavale
9,735 Recognized Expert Moderator Expert
Um, I was indenting your code for the Measurement class noticed a bunch of errors.

First of all you have:

Expand|Select|Wrap|Line Numbers
  1. public class Measurement{
  2. {
Are you supposed to have 2 open curly braces??

Then after you close your printScreenInch method...you have a bunch of variables declared (??) followed by a bunch of System.out.prin tln() statements. I don't even know what would happen if this did compile.

Please check over your code because I'm sure there are more syntax errors.
You will probably find a lot of your errors if you properly indent your code.


-Frinny
Dec 17 '09 #4

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

Similar topics

2
1906
by: Eric S. Johansson | last post by:
I've been playing with the profiler and have been rather successful in making my code run faster. So for my best success has been cutting a three second CPU time run down to about 0.45 seconds. Unfortunately, the same application seems to take about 8 to 12 seconds real-time. I know that some of that time is lost to file IO and external sub processes but I don't know how much. Is there any way to change the profiler to measure...
114
9885
by: Maurice LING | last post by:
This may be a dumb thing to ask, but besides the penalty for dynamic typing, is there any other real reasons that Python is slower than Java? maurice
37
4337
by: asj | last post by:
awhile back, eBay decided to switch from a Microsoft/.NET/Windows architecture on the backend to a J2EE one, which might explain why their java backend will handle up to 1 BILLION page views a day! the funny thing was eBay was one of the major case studies for .NET at the beginning, when there was still some hype about it. interesting post about a few java case studies: http://weblogs.java.net/pub/wlg/268 "I love looking through case...
0
2671
by: Alex Vinokur | last post by:
=================================== ------------- Sorting ------------- Comparative performance measurement =================================== Testsuite : Comparing Function Objects to Function Pointers Source : Technical Report on C++ Performance Tool : The C/C++ Program Perfometer (Version 2.8.1-1.19-Beta) * http://sourceforge.net/projects/cpp-perfometer/
0
1305
by: UrsusMaximus | last post by:
One measurement by which Python is more popular than Ruby, Java, Perl, PHP and .NET is in the world of Podcasts. At Podcastalley, podcasts are ranked by popularity in each of several genre's. In the "Technology" genre there are 1026 podcasts listed and ranked, and of the ones that are about programming languages and related areas, they show up in the rankings like this: 32. Python411 44. Perlcast 49. ProPHP
458
21481
by: wellstone9912 | last post by:
Java programmers seem to always be whining about how confusing and overly complex C++ appears to them. I would like to introduce an explanation for this. Is it possible that Java programmers simply aren't smart enough to understand C++? This is not merely a whimsical hypothesis. Given my experience with Java programmers --- the code they write and the conversations they have --- Occam's Razor points to this explanation. For example,...
3
23419
by: shanakard | last post by:
i am writing a program for string matching (for a assignment @ our campus) i want to measure the cpu tick count(or verry accurate time measurement, maybe in icro seconds or so...) to analyze running time. can i do this in java and f so how?
358
13206
by: King Raz | last post by:
The shootout site has benchmarks comparing different languages. It includes C# Mono vs Java but not C# .NET vs Java. So I went through all the benchmark on the site ... http://kingrazi.blogspot.com/2008/05/shootout-c-net-vs-java-benchmarks.html Just to keep the post on topic for my friends at comp.lang.c++, how do I play default windows sounds with C++?
4
1738
by: sgxbytes | last post by:
Hi, I have text file which contains data in this way DEBUG ooegroup.OoeGroupOnlineInterfaceImpl - PERFORMANCE MEASUREMENT :: BEFORE OOE RESERVE GROUP MEMBER Info >>>> Fri Apr 03 10:16:47 ICT 2009> DEBUG ooegroup.OoeGroupOnlineInterfaceImpl - reserveOOEGroup :> DEBUG ooegroup.OoeGroupOnlineInterfaceImpl - PERFORMANCE MEASUREMENT :: AFTER OOE RESERVE GROUP MEMBER Info >>>> Fri Apr 03 10:16:48 ICT 2009> DEBUG...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10315
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10083
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7494
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.