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");
}
}