Hey i'm writing this code...and well.
I'm very new to java ><...
There are two things that I am trying to do,
Basically, without using Arrays,
- I want to write a program that asks the user how many integers that they want to input, then have the user input those variables and then have the program determine and display the minimum and maximum values of whatever the user inputs.
This is what I have so far but it isn't working...
// Import Scanner Class import java.util.Scanner; public class maxMinValues { // main method is the start point of java applications public static void main(String args[]) { // variable to read user input Scanner input = new Scanner(System.in); //Title System.out.printf("\t\n Finding the largest & smallest Value "); System.out.printf("\t\n How many integers are "); //Variables int lowValue=0; int a=0; int b=0; int c=0; int d=0; int e=0; while ( a >= 0 ) { System.out.printf("\n\n Enter Integer: "); a = input.nextInt(); if ( a == -100 ) { break; } } if (a <= b && a <= c && a <= d && a <= e || a == b || a == c || a == d || a == e) lowValue = a; else if (b <= a && b <= c && b <= d && b <= e || a == b || b == c || b == d || b == e) lowValue = b; else if (c <= a && c <= b && c <= d && c <= e || c == a || c == b || c == d || c == e) lowValue = c; else if (d <= a && d <= b && d <= c && d <= e || d == a || d == b || d == c || d == e) lowValue = d; else if (e <= a && e <= b && e <= c && e <= d || e == a || e == b || e == c || e == d) lowValue = e; System.out.printf ("\n Min Value:%d", lowValue); } int highValue=0; int a=0; int b=0; int c=0; int d=0; int e=0; { if (a >= b && a >= c && a >= d && a >= e) highValue = a; else if (b >= a && b >= c && b >= d && b >= e) highValue = b; else if (c >= a && c >= b && c >= d && c >= e) highValue = c; else if (d >= a && d >= b && d >= c && d >= e) highValue = d; else if (e >= a && e >= b && e >= c && e >= d) highValue = e; System.out.printf ("\n Max Value:%d", highValue); } // end main() } // end class
Then...
- program that converts temperatures from -5 to 15 C. by increments of 1 to Fahrenheit. Repeating it 3 times 1 with a for loop, 1 with while and 1 with do.
// Import Scanner Class import java.util.Scanner; public class tempConvert { // main method is the start point of java applications public static void main(String args[]) { // variable to read user input Scanner input = new Scanner(System.in); //Title System.out.printf("\t\n Celcius To Fahrenheit (-5 to 15) "); int getFahrenheit=0; for (int f= getFahrenheit(); f <= 212; f= getFahrenheit()) System.out.println(f+"F = "+convertToC(f)+"C"); System.out.println("Enter temperature in "); // prompt for input x = input.nextInt(); // read first integer in farenheit result = (5.0/9)*(x-32); System.out.println("Fahrenheit Celsius", result); } //end method main } // end class
- Im not sure how to input the other 2 loops aswell >< ugh.
no idea what to do after this point. I'm using blueJ btw:
if someone could help that would be wonderful.
thanks. >.<