4 Replies - 729 Views - Last Post: 28 February 2015 - 10:02 PM Rate Topic: -----

#1 khafia7  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 28-February 15

Very New to Java, Topic: Integers

Posted 28 February 2015 - 12:44 PM

Hi, I'm very new to Java and would appreciate any help I can receive :)/>
How would I even start these programs?







1.) Write a program Smallest that reads three integers from the user and determines the smallest value.

2.) Write a program InOrder that reads in three integers and prints the three integers in sorted order. Use if and if-else statements to compare 3 numbers and sort them.

Output (numbers in red were entered by the user):


Type three integers: 3 6 2

The integers in sorted order are: 2 3 6


3) Write a program MonthsUsingIf that asks the user to enter a month (1 = January, 2 = February, and so on) and then prints the number of days of the month. For February, print "28 days". Use if statements for this program.

4) Write a program MonthsUsingSwitch that asks the user to enter a month (1 = January, 2 = February, and so on) and then prints the number of days of the month. For February, print "28 days". Use switch statement for this program.


Is This A Good Question/Topic? 0
  • +

Replies To: Very New to Java, Topic: Integers

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13954
  • View blog
  • Posts: 55,699
  • Joined: 12-June 08

Re: Very New to Java, Topic: Integers

Posted 28 February 2015 - 12:47 PM

Break the problems down.

In in the first one.. it asks for you to get three values from a user. What would you do to read key inputs from a console window? What would you do to store those inputs in, say, three integers? Comparing them sounds like a job for a series of 'if' statements.
Was This Post Helpful? 0
  • +
  • -

#3 blackeagle123  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 66
  • Joined: 28-November 13

Re: Very New to Java, Topic: Integers

Posted 28 February 2015 - 02:45 PM

at least show us what you tried to do !! or you didn't try at all ?
Was This Post Helpful? 0
  • +
  • -

#4 djjeavons  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 114
  • View blog
  • Posts: 417
  • Joined: 09-January 09

Re: Very New to Java, Topic: Integers

Posted 28 February 2015 - 04:11 PM

View Postkhafia7, on 28 February 2015 - 12:44 PM, said:

Hi, I'm very new to Java and would appreciate any help I can receive :)/>/>
How would I even start these programs?


The suggestion to break down each problem is a very good one, but I wonder, by your statement of how would I event start these programs, if you are missing the very basics? I don't mean to sound patronising but give us an idea of the level you are at at the moment. If you are a complete beginner that doesn't know how to start writing the code, please say so, that's fine, we were all beginners once. Or if it is a case of, I know how to start writing code but don't know how to approach these problems then also please say so.
Was This Post Helpful? 0
  • +
  • -

#5 V-lad  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 21
  • Joined: 20-February 15

Re: Very New to Java, Topic: Integers

Posted 28 February 2015 - 10:02 PM

I would have to agree with the posts above. I see that really the first two and last two problems are similar to each other. The first two questions both ask for a trio of integers that are then sorted, then the last two ask for a single integer input that then returns a string depending on the input. All of those questions are fairly easy in reality. I would start with the bare minimum basics.... Start by setting up the main method, use a few output lines to prompt for input, then add your collector for input, then with this you can set up a good half of all 4 of these problems. As it states in the forum - We will not do your homework for you! But we are here to help. At the least, take a shot at what you may think it would start with and the group can coach you from there - and its a good group - but if it looks that you are not willing to put forth at least a decent amount of effort, then dont even bother posting. Mind you - Im not saying you didnt try, just that your post makes it seem that way. Take a shot and show us some code!!!!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1