Assignment9 - /Assignment 9/Name Johrdyn...

This preview shows page 1 - 2 out of 2 pages.

//Assignment #: 9 //Name: Johrdyn Lorden //StudentID: 1201666366 // Lecture: MWF 1:30pm //Description: This class reads a double from a keyboard and performs operations on it. import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.Scanner; public class Assignment9 { public static void main (String[] args) { Scanner scan = new Scanner(System.in); double[] numList = new double[100]; double number = 1; int count = 0; int index = 0; while (number != 0) { number = scan.nextDouble(); numList[index] = number; index++; } DecimalFormat f = new DecimalFormat("###.##"); System.out.println("The maximum number is " + f.format(findMax(numList, 0))); System.out.println("The total number of negative numbers is " + f.format(countNegative(numList, 0))); System.out.println("The sum of positive numbers is " + f.format(computeSumPositive(numList, 0))); scan.close(); } //-> It finds the maximum number in the array, count is the number of

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture