Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a statement if with: Ask user if they would like donate, accept ‘y’ for ye

ID: 3680758 • Letter: W

Question

Write a statement if with:

Ask user if they would like donate, accept ‘y’ for yes or ‘n’ for no answer.

LOOP while user answer is ‘y’

Ask for donor’s full name

Ask user for credit card number

Create instance of Donation class

IF credit card number is valid

Ask user for donation

amount

Validate amount donated. Keep asking user for amount if amount is 0 or less.

Update donation amount when it passes validation.

Call method to display summary information

Display issuer name

ELSE

Display message “Invalid credit card number

.”

END IF

Ask user if user wants to make another donation

END LOOP

Explanation / Answer

class Donation{
String issuername;
int donationamount;
String creditcardnumber;
public void summary(){

System.out.println("donor registered");
System.out.println("issuer name:"+issuername);
}
public static void main(String... s){
Scanner sc=new Scanner(System.in);
char choice;
System.out.println("would you like to donate, enter y for yes and n for no");
choice=sc.next();
while(choice=='y'){
System.out.println("enter your full name");
String donorname=sc.next();
System.out.println("enter your credit card number");
String creditcardnumber=sc.next();
if(creditcardnumber.length()==16)
{Donation d=new Donation();
System.out.println("enter donation amount");
int amount=sc.nextInt();
if(amount<=0 && amount<=1000)
System.out.println("pls donate amount more than 1000");
else
d.donationamount=amount;
d.issuername=name;
}else{
System.out.println("invalid credit card number")
}
d.summary();
System.out.println("do you want to make another donation");
choice=sc.next();
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote