Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

So i'm stuck , this is supposed to keep track of 17 people and their donations in an array so far this is what I

So i'm stuck , this is supposed to keep track of 17 people and their donations in an array so far this is what I have it is close however its not functionig properly any help is appreciated

import java.util.Scanner;

import java.util.Locale; import java.text.NumberFormat;

public class Donations07 { public static void main(String[] args) { NumberFormat us =NumberFormat.getCurrencyInstance(Locale.US); Scanner input= new Scanner(System.in); String []donorName = new String [17];//These set the double []amtDonated= new double[17]; double []totalDonations = new double [17]; int []numDonations = new int[17]; double grandTotalDonations =0.0;

for(int i=0;i<17;i++) { System.out.print("Donor"); donorName[i]= input.nextLine(); System.out.print("Amount of Donation"); amtDonated[i]= input.nextDouble(); System.out.println(+amtDonated[i]); while(amtDonated[i]<5.0) { System.out.print("Minimum donation is $5.00, please try again"); amtDonated[i]=input.nextDouble();} System.out.print("Number of Donations");

numDonations[i]=input.nextInt(); System.out.println(+numDonations[i]); while (numDonations[i] <1); { System.out.print("You must have at least 1 donation please try again"); numDonations[i]=input.nextInt(); } totalDonations[i]=amtDonated[i]*numDonations[i]; grandTotalDonations= grandTotalDonations + totalDonations[i];} for(int i=0;i<17;i++) { System.out.print("Donor#" + (i+1)+"Donor"+us.format(donorName[i])); System.out.print("Amount of Donation:"+us.format(amtDonated[i])); System.out.print("Donors Total Amount :" +us.format(totalDonations[i])); System.out.print("Grand Total of all donations"+us.format(grandTotalDonations)); } input.close();

}//main

}//class

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle Database Architecture

Authors: Thomas Kyte, Darl Kuhn

3rd Edition

1430262990, 9781430262992

Students also viewed these Databases questions

Question

1. Where do these biases come from?

Answered: 1 week ago

Question

7. What decisions would you make as the city manager?

Answered: 1 week ago