473,387 Members | 1,536 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,387 software developers and data experts.

Help with Program!

Currently I was assigned an assignment that goes like this:

Write an application that reads values representing a time duration in hours, minutes and seconds and then prints the equivalent total number of seconds.

I use Eclipse to write my software and not that familiar with Java.

Here's what I got so far.

Expand|Select|Wrap|Line Numbers
  1. public class TimeDuration {
  2. //
  3.     //  Prints a time duration from hours, minutes, and seconds and converts it into seconds
  4.     //
  5.      public static void main (String[] args)
  6.      {
  7.          double hours, minutes, sec, Xsec;
  8.  
  9.          Scanner scan = new Scanner (System.in);
  10.  
  11.          System.out.print("Enter the number of hours: ");
  12.          hours = Double();
  13.  
  14.          System.out.print ("Enter the number of minutes: ");
  15.          minutes = Double();
  16.  
  17.          System.out.print("Enter the number of seconds: ");
  18.          sec = Double();
  19.  
  20.          Xsec = hours * minutes * sec;
  21.  
  22.          System.class.println ("Time Duration of :" + Xsec);
  23.  
  24.  
  25.      }
  26.                         }
Can someone tell me what am I doing wrong and help correct those mistakes?

Thanks a whole lot.
Feb 14 '08 #1
7 4322
BigDaddyLH
1,216 Expert 1GB
What syntax errors do you have?
Feb 14 '08 #2
hirak1984
316 100+
Expand|Select|Wrap|Line Numbers
  1. System.class.println ("Time Duration of :" + Xsec);
this should be

Expand|Select|Wrap|Line Numbers
  1. System.class.println ("Time Duration of :" + Xsec);
Feb 14 '08 #3
Expand|Select|Wrap|Line Numbers
  1. System.class.println ("Time Duration of :" + Xsec);
this should be

Expand|Select|Wrap|Line Numbers
  1. System.class.println ("Time Duration of :" + Xsec);

That looks like the exact same thing with no changes.
Feb 14 '08 #4
What syntax errors do you have?
Here's the list of errors that showed up after I ran the program,

The method Double() is undefined for the type TimeDuration
The method Double() is undefined for the type TimeDuration
The method println(String) is undefined for the type Class

at TimeDuration.main(TimeDuration.java:10)
Feb 14 '08 #5
r035198x
13,262 8TB
Expand|Select|Wrap|Line Numbers
  1. System.class.println ("Time Duration of :" + Xsec);
this should be

Expand|Select|Wrap|Line Numbers
  1. System.class.println ("Time Duration of :" + Xsec);
You mean System.out.println( ... ?
Feb 14 '08 #6
JosAH
11,448 Expert 8TB
Here's the list of errors that showed up after I ran the program,

The method Double() is undefined for the type TimeDuration
The method Double() is undefined for the type TimeDuration
The method println(String) is undefined for the type Class

at TimeDuration.main(TimeDuration.java:10)
What is the method Double() supposed to do? There certainly isn't a method
named Double() defined in that class (as the compiler tried to tell you).

That 'class' thingy was just a silly litle mistake.

kind regards,

Jos
Feb 14 '08 #7
hirak1984
316 100+
You mean System.out.println( ... ?
well precisely yes.
i m sorry 4 the mistake
Feb 18 '08 #8

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

Similar topics

4
by: PHPkemon | last post by:
Hi there, A few weeks ago I made a post and got an answer which seemed very logical. Here's part of the post: PHPkemon wrote: > I think I've figured out how to do the main things like...
6
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing...
5
by: Bec | last post by:
I'm in desperate need of your help.. I need to build an access database and have NO idea how to do this.. Not even where to start.. It IS for school, and am not asking anyone to do my...
7
by: tyler_durden | last post by:
thanks a lot for all your help..I'm really appreciated... with all the help I've been getting in forums I've been able to continue my program and it's almost done, but I'm having a big problem that...
2
by: Erik | last post by:
Hi Everyone, I'm having real problems compiling some source for eVC4++. The errors I am getting are below: It all seems to be centred around winsock. If I move the afsock.h reference to before...
2
by: Bsnpr8 | last post by:
I need help guys, i have to many stuff to do, because i am in my last 2 weeks of the university, my last assignment is to do a spell checker in C++, i have an idea but nothing is coming out. I really...
6
by: HelpME | last post by:
I wrote a program in Vb.Net that was running fine. However I am unable to install it on a couple of machines. When i run it I get a windows error message that says My Project.exe has...
1
by: ligong.yang | last post by:
Hi all, I got tortured by a very weird problem when I was using k. wilder's random generator class in my program. PS: wilder's generator class can be found at...
1
by: ligong.yang | last post by:
Hi all, I got tortured by a very weird problem when I was using k. wilder's random generator class in my program. PS: wilder's generator class can be found at...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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
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,...
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...

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.