import java.util.Scanner; public class Donations { public static void main(String[] args) { Scanner keyboard= new Scanner (System.in); String donorName; int donationAmount, donationQuantity=0, maxDonation=0; do { System.out.println("Please enter your name"); donorName=keyboard.nextLine(); System.out.println("Please enter donation amount"); donationAmount=keyboard.nextInt(); donationQuantity=donationQuantity+1; maxDonation +=donationAmount; } while (maxDonation<500); System.out.println("It took " + donationQuantity + " donations to reach the £500"); }//main }//class
For some reason when the program loops the second time for a new customer to enter the name, the amount prompt appears directly below it, therefore not being able to enter the 2nd name. Any ideas guys?


LinkBack URL
About LinkBacks
Reply With Quote