Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

# Thread: java begginner homework help

1. ## java begginner homework help

I have to make 3 different programs to compile and the are the instructions.

Instructions:
Part One: Code a for loop to print the Celsius temperatures from 0-100 and the corresponding Fahrenheit temperature, and the approximate Fahrenheit temperature (2*Celsius + 32). Output should be in a table format:
Celsius Fahrenheit Approximate Fahrenheit
0 32.0 32.0
1 33.8 34.0
2 … …
Part Two: Code a while loop to read in and total any number of positive numbers terminated with a 999 as a sentinel. If the user types in a negative number, do not add it to the total, just go on to the next number. Print the total, once, after the loop is finished. Run twice with different values and different number of values. Use easy numbers that I can add in my head but be sure to add some negative numbers!
Part Three: Code a do while loop to ask a user to guess a number between 1-10, which has been randomly generated by the computer. After each guess, with an if statement, tell the user whether his guess was too high or too low and allow him to guess again until he guesses the correct number. Run twice.

This is what I have, I'm really bad at programming so any help will be appreciated

1. import java.util.Scanner;
public class lab4a
{

public static void main(String[] args)
{
for(int celsius = 0; celsius<= 100; celsius++)
{
false = 9.0/5.0*celsius + 32;
approximate = 2*celsius + 32;
System.out.println(celsius + "\t" + false + "\t" + approximate);

System.out.println("celsius \t Fahrenheit \t approximate Fahrenheit");
while (condidtion);
int i = 1;
while(1 =10);
{
System.out.println(i);
}
}

2. import java.util.Scanner;
public class lab4b
{

public static void main(String[] args)
{
final int SENTINEL = 999;
int n,amount = 0;
System.out.println("Type in a number or 999 to stop");
n = Scan.nextInt();
while(n != SENTINEL)
{
if(n > 0)
total = n;
System.out.println("Type in a number or 999 to stop");
n = Scanner.nextInt();
}
System.out.println(total);
}

3. import java.util.Scanner;
public class lab4c
{

public static void main(String[] args)
{
int number;
Scanner Scan = new Scanner(System.in);

do
{
System.out.println("Enter number between 1 and 10");
number = Scan.nextInt();
}
while(number < 1 || number > 10);
System.out.println("right number");
}
}  Reply With Quote

3. ## Re: java begginner homework help

Do you have a question?  Reply With Quote

4. ## Re: java begginner homework help

Welcome to the Forum! Please read this topic to learn how to post code correctly and other useful tips for newcomers.

Please post your code correctly per the above link and ask a specific question.  Reply With Quote

5. ## Re: java begginner homework help

I'm really bad at programming
Do not put yourself down like that - the fact that you can write code in any form
means you can program, and you are understanding the basic features of the
language. Everyone has to start somewhere - no body is born gifted at anything.
We were all beginners at one point   Reply With Quote

6. ## Re: java begginner homework help

[QUOTE=kiba;156317]I have to make 3 different programs to compile and the are the instructions.

Instructions:
Part One: Code a for loop to print the Celsius temperatures from 0-100 and the corresponding Fahrenheit temperature, and the approximate Fahrenheit temperature (2*Celsius + 32). Output should be in a table format:
Celsius Fahrenheit Approximate Fahrenheit
0 32.0 32.0
1 33.8 34.0
2 … …
Part Two: Code a while loop to read in and total any number of positive numbers terminated with a 999 as a sentinel. If the user types in a negative number, do not add it to the total, just go on to the next number. Print the total, once, after the loop is finished. Run twice with different values and different number of values. Use easy numbers that I can add in my head but be sure to add some negative numbers!
Part Three: Code a do while loop to ask a user to guess a number between 1-10, which has been randomly generated by the computer. After each guess, with an if statement, tell the user whether his guess was too high or too low and allow him to guess again until he guesses the correct number. Run twice.

This is what I have, I'm really bad at programming so any help will be appreciated

``` import java.util.Scanner;
public class lab4a
{

public static void main(String[] args)
{
for(int celsius = 0; celsius<= 100; celsius++)
{
false = 9.0/5.0*celsius + 32;
approximate = 2*celsius + 32;
System.out.println(celsius + "\t" + false + "\t" + approximate);

System.out.println("celsius \t Fahrenheit \t approximate Fahrenheit");
while (condidtion);
int i = 1;
while(1 =10);
{
System.out.println(i);
}
}```

``` import java.util.Scanner;
public class lab4b
{

public static void main(String[] args)
{
final int SENTINEL = 999;
int n,amount = 0;
System.out.println("Type in a number or 999 to stop");
n = Scan.nextInt();
while(n != SENTINEL)
{
if(n > 0)
total = n;
System.out.println("Type in a number or 999 to stop");
n = Scanner.nextInt();
}
System.out.println(total);
}```

``` import java.util.Scanner;
public class lab4c
{

public static void main(String[] args)
{
int number;
Scanner Scan = new Scanner(System.in);

do
{
System.out.println("Enter number between 1 and 10");
number = Scan.nextInt();
}
while(number < 1 || number > 10);
System.out.println("right number");
}
}```  Reply With Quote

7. ## Re: java begginner homework help

Can you explain what problems you are having or ask some specific questions about the programs?

If you are getting errors, copy the full text of the error messages and paste it here.  Reply With Quote