• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Future computer science student

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,
in january i will be starting a computer science class using java. i went ahead and got the book so i could start practicing and hopefully stay on top of everything. i have come across a project that i just cant seem to figure out. i have got the first part accomplished but i am not doing something right with the numbers in the next part.

i put 2 hours of tv a day on the first part so that would be 7300 hours , 304.16666666666666666666666666667 days , or 0.83333333333333333333333333333334 years watching tv! i cant figure out how i am suppose to enter it, and doing something wrong with the tab and spacing.

also under the to do list it says to write a pseudocode algorithm for this and to write your program one step at a time. doesnt this mean the same thing?

any help would be appriciated!
sorry for adding all this to email but it wouldn't let me attach anything
chris


You should be able to:
• Use sequential logic to write an algorithm
• Create a simple class to do some input from the keyboard, output and simple calculations
• Declare and define identifiers of primitive types
• Use constant identifiers where appropriate
• Request and process input from the keyboard
• Perform basic mathematical operations
• Display output to the monitor
The Project

Develop a simple program in Java that will interact with the user through some dialog. It will ask the user for his/her name and the number of hours that the watches TV per day (on average). The program will then display to the user the approximate number of hours and the equivalent number of days and the equivalent number of years that the user will have spent watching TV over the next 10 year

Notes:
• The average hours of TV watched per day can have a decimal place when entered (ex, 2.5 or 5.3 or 6)
• The output should look exactly like that shown in the examples (pay close attention to line breaks and spacing)
• You can make the following assumptions: there are 24 hours in a day, 365 days in a year. This program does not account for leap years. Obviously, using 365 days in a year is not totally accurate, but it makes the solution to this problem much simpler
• Since there are always 24 hours in a day and 365 days in a year (for this program, anyway) you should make these constant values
• This program should be designed such that the number 10 years can easily be changed by the programmer in one place rather than throughout the program

PROJECT TO DO LIST:
 Write a pseudocode algorithm for this project Test your algorithm before coding
 Create a class called Project1 containing a method called main (which contains the code to implement this project). Your project should be saved in a folder named LastnameFirstnameProject1 (replace Lastname and Firstname with your own last and first name)
 Write your program one step at a time, i.e. make sure one thing works before going on to something else. For instance, write the part that asks for the users name and says hello back to the user (and test it to make sure that it works) before writing the rest of the code
 Test your program to make sure that it works!
 Complete the documentation of the application by inserting comments and adhering to programming standards
 
Ranch Hand
Posts: 231
Android IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you summarize what your question is? Can't work out what your asking
 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to Java Ranch!

You will find that the more effort you put into a problem prior to posting about it the better and quicker responses you will get. Please post your best code for solving the problem and ask a specific question about it.

ShowSomeEffort
 
christopher Shepstead
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Develop a simple program in Java that will interact with the user through some dialog. It will ask the user for his/her name and the number of hours that the watches TV per day (on average).***I completed this part.

The program will then display to the user the approximate number of hours and the equivalent number of days and the equivalent number of years that the user will have spent watching TV over the next 10 year.

I having trouble with this. It is suppose to look like this example:
7300 hours , or
304.16666666666666666666666666667 days, or
0.83333333333333333333333333333334 years watching TV!

not sure if i am suppose to use the Scanner keyboard=new Scanner(System.in);
or if i am suppose to just do System.out.print("....");

and it is suppose to be tabbed. i believe the correct way to do that is to insert '\t' a the beginning of the statement but when i try to compile it shows a bunch of errors.
 
Bobby Smallman
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Remember that one time when I suggested you post your actual code along with a specific question? Good times.
 
James Elsey
Ranch Hand
Posts: 231
Android IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with Bobby,

Whack up some code here for us to have a look at (be sure to use the code tags or its a major brain-ache to read)

I'll then suggest you some pointers on what you can try, but I need to see what you have first
 
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please tell us what the threads are about; it isn't about a student at all.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

christopher Shepstead wrote:also under the to do list it says to write a pseudocode algorithm for this and to write your program one step at a time. doesnt this mean the same thing?


Nope. Pseudo-code is text that looks a bit like code, but isn't, but is expressive enough to be translated relatively easily into actual code.

Writing your program one step at a time means to complete a very tiny portion of the complete program, make sure that works, then move on to the next bit.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

christopher Shepstead wrote:when i try to compile it shows a bunch of errors.


It is pointless to write "it shows a bunch of errors". WHAT the errors are is not just significant, it's really the point. HOW you fix the errors is determined by what those errors are. Solving a "could not find javac.exe" error is a vastly different problem than a "no such method: System.out.print1n()" error.

So...if you want help fixing your 'bunch of errors', you need to do two thing - and do both of them:

1) Post your code so we can see exactly what you are doing (and use code tags!!!)
2) Post the EXACT TEXT of the errors

Once you do that, you will get more help that you could ever want.
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Christopher,

The project description in your post does not look like something out of a book; it looks more like an assignment from an online class ("Your project should be saved in a folder named LastnameFirstnameProject1"). Just saying...

Anyway, to answer the one specific thing you asked about, the Scanner class is used for input. For output to the screen, you'd use System.out.println() or something similar. The tab characters (and any other special characters, like newline characters) should be a part of the string being output, like so:



That should help get you started. If you need more guidance, then as others have mentioned, it helps to post your actual code, any error messages you're getting, and specific questions!
reply
    Bookmark Topic Watch Topic
  • New Topic