Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started