# Thread: Help me pls It is my homework:(

1. Member Join Date
Oct 2010
Posts
10
Rep Power
0

## Help me pls It is my homework:(

question1)(Finding the smallest n such that n2 > 12000) Use a while loop to find the smallest integer n such that n is greater than 12,000.

2)Finding the largest n such that n3 < 12000) Use a while loop to find the largest integer n such that n is less than 12,000.

3)(Computing future tuition) Suppose that the tuition for a university is \$10,000 this year and increases 5% every year. Write a program that uses a loop to compute the tuition in ten years. Write another program that computes the total cost of four years' worth of tuition starting ten years from now.

4)(Finding the two highest scores) Write a program that prompts the user to enter the number of students and each student's name and score, and finally displays the student with the highest score and the student with the second-highest score.

I hope answers :(((  Reply With Quote

2. Member Join Date
Oct 2010
Posts
2
Rep Power
0

## Since I asked a question only fair I answer one.

I don't want to answer your homework for you, but if you know how to create a class and compile it, for the first three questions, I will explain a while loop.

A while loop tests to see if a statement meets a condition, if it does meet the condition, run some code, if it doesn't, then skip the code...

So lets say we had this:

int a = 6;
while(a < 10)
{
System.out.print(a);
a = a +1;
}

The output on the screen would be:
6
7
8
9

It would stop at 9, because 10 would be above 9. A while statement tests the condition, evaluates it, and if it meets the condition, it runs the code, since the code adds 1 to a, a keeps increasing until it gets to 10. I am not sure if this was clear, the ending value of a would be 10, it just would not print because of where the print statement was located. If the print statement and the a = a+1 lines were switched in order, it would print 7, 8, 9, 10 instead. Hope that helps.

For question number 4, thats a lot harder than the rest. It will be helpful to look at java.io api. java.io (Java 2 Platform SE v1.4.2) may be helpful.

Good luck.
Last edited by RichW; 10-19-2010 at 09:57 PM.  Reply With Quote

3. Member Join Date
Oct 2010
Posts
9
Rep Power
0

## I will give you idea :)

q1: make first input as (smallest) ... Declare variable smallest ..

then make compare between it and next input ... if next input small than it

make smallest equal the new input ...

of course inside loop ...  Reply With Quote

4. ##  Originally Posted by pinar I hope answers :(((
I'm sorry, but this is nothing but a homework dump where you've posted an assignment word for word without demonstrating a lick of work. Please do yourself and us a favor by showing the work you've done and not posting homework in the forum without showing what you've tried and what specific questions you may have.  Reply With Quote

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•