
Below was the java code that i was hald done on it.
in the java code, it supposed to count on min and max rainfall.
the min and max rainfall should update on every rainfall entry.
Don’t mind help me find out the mistake and amend on it.
import java.util.Scanner;
public class draft {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner kb = new Scanner(System.in);
int totalCount = 0;
double totalRainFall = 0;
double minRainFall = 0;
double maxRainFall = 0;
double aveRainFall = 0;
System.out.println("Rainfall Level Counter");
System.out.println();
System.out.print("Enter Rainfall Level: ");
double rainFall = kb.nextDouble();
while(rainFall > 0) {
totalCount++;
totalRainFall += rainFall;
if (rainFall > minRainFall) {
minRainFall = rainFall;
if (rainFall < maxRainFall) {
maxRainFall = rainFall;
}
}
System.out.print("Min: " + minRainFall +" ");
System.out.print("Max: " + maxRainFall +" ");
aveRainFall = totalRainFall/totalCount;
System.out.print("Ave: " + aveRainFall +" ");
System.out.println();
System.out.println();
System.out.print("Enter Rainfall Level: ");
rainFall = kb.nextDouble();
kb.nextLine();
}
if(rainFall <= 0) {
System.out.println("Rainfall Entries Made: " + totalCount);
}
}
}
The program should run as show below :
Enter rainfall : 3.2 Min : 3.2 Max : 3.2 Ave : 3.2
Enter rainfall : 3.8 Min : 3.2 Max : 3.8 Ave : 3.5
Enter rainfall : 2 Min : 2.0 Max : 3.8 Ave : 3.0
Enter : -1 Rainfall entries made : 3
|
But now the output was show as below :
Enter rainfall : 3.2 Min : 3.2 Max : 0 Ave : 3.2
Enter rainfall : 3.8 Min : 3.8 Max : 0 Ave : 3.5
Enter rainfall : 2 Min : 3.8 Max : 0 Ave : 3.0
Enter : -1 Rainfall entries made : 3
|

Step by stepSolved in 3 steps with 3 images

- Java - How to make this a horizontal statement with a newline. Whenever I use System.out.println, it makes the output vertical instead of horizontal. What am I doing wrong? Program below. import java.util.Scanner; public class LabProgram { public static void main(String[] args) { int i; String InputString; Scanner sc = new Scanner(System.in); InputString = sc.nextLine(); char[] strArray = new char[InputString.length()]; for(i = 0; i < InputString.length(); i++){ strArray[i] = InputString.charAt(i); } for(i = 0 ; i< InputString.length() ; i++) if(strArray[i] >= 'a' && strArray[i] <= 'z' || strArray[i] >= 'A' && strArray[i] <= 'Z') System.out.print(strArray[i]); (the problem line) }}arrow_forwardHelp writing a Java program (please provide photos it works so I'm not studying a nonworking program) Write a complete version of the Bresenham Midpoint algorithm to handle ALL slope values. Include appropriate tests for ‘special case’ conditions. Instead of “WritePixel” write to the screen the coordinates of the pixel that would be drawn. Your program must implement the algorithm given in class with modifications to handle the special cases. Different slope values: m = 0, m = 1, m = > 1, m = infinity (needs special test case) , m < 0 (swap x and y) The user should be able to enter coordinates and it should output the coordinates it takes to draw from the first point to the last pointarrow_forwardI did part A but I really need all parts of part B answered I want the code to continue after 0 with negative numbers and I need the guesses to show up at the end that shows how many guesses it took before the user ran out of points. import java. util.Random; import java.util. Scanner; import java.util.regex.*; public class HiLOGame{ public static void main( String(] args){ final int MAX POINT = 1000- int point = MAX POINT: int numberOfGuess = 0; do { numberOfGuess++: showStatus(point); int point ToRisk = getPointToRisk("Enter point to risk? ", point); String option = getHiLoOption ("Enter either Hi or Lo?"); int magicNumber = getMagicNumber(1, 13); /I for debug //System.out.printf(String.format ("Magic number: %d%n",. magicNumber)); if (isWon(option, magicNumber)) { point += pointToRisk: System.out.printin("You Won this game."); } else f point -= pointToRisk: System.out.printin("You Lost this game."); } }while (point > 0): report(MAX POINT, numberOfGuess); System.exit(0); }…arrow_forward
- Write out the memory snap shot of all declared variables after the following is executed. double a=3.5, x; int n=2, y; y=a/n; x=y*2; You do not need to put box around the memory values, just write x = value for each of the values. As an example, the memory map after the variable declarations and before the mathematical assignments would be written: a = 3.8 X = ? n = 2 y = ? Your Answer:arrow_forwardPlease write a complete java programarrow_forwardthe java file is here. and the question is attached as a photo. i // **************************************************************** // ParseInts.java Authors: Lewis, Loftus & DuVall-Early // Date: 4/17/21 // // Reads a line of text and prints the integers in the line. // // **************************************************************** import java.util.Scanner; public class ParseInts { //--------------------------------------------- // main method //--------------------------------------------- public static void main(String[] args) { int val, sum=0; Scanner scan = new Scanner(System.in); System.out.println("Enter a line of text"); Scanner scanLine = new Scanner(scan.nextLine()); while (scanLine.hasNext()) { val = Integer.parseInt(scanLine.next()); sum += val; } System.out.println("The sum of the integers on this line is " + sum); scan.close(); scanLine.close(); } }arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





