Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question
100%

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

 

 

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education