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

Help needed in java program ! Thanx A major credit card offers a cash back progr

ID: 3907683 • Letter: H

Question

Help needed in java program ! Thanx

A major credit card offers a cash back program based on the amount of charges made on the card during a year. Charges Cash Back 196 396 5% Less than $10,000 $10,000 - $50,000 Over $50,000 Gold card members receive an additional 2% back (regardless of amount of total charges). Write a program that ask the user for their annual charges and whether they are a Gold card member. Then calculate and display the cash back the user receives as well as the percentage (1%, 3%, 5%, etc) that they qualifed For the Gold member part of the prorgam, ask the user to enter 1 if they are a member and 2 if they are not a member. (There are other ways to do this, you are welcome to try. This method avoids some issues with reading and testing different data types.) Submit your .java file in our course shell. If you are having trouble, check out the following sample program.

Explanation / Answer

import java.util.*; //package having Scanner object

public class CredtCardOffer{

public static void main(String args[]){

Scanner in= new Scanner(System.in); //Scanner to get input from system

System.out.println("Enter Annual charges : ");

int charges=in.nextInt(); //store annual charges

System.out.println("If you are Gold card member enter 1, else press 2 : ");

int member=in.nextInt (); //store value for user is Gold card member or not

int cashback=0;

double tcashback;

//if member is Gold then add additional 2% cashback further need not to be updated

if(member==1){

cashback=2;

}

if(charges<10000){ //check annual charges are less than 10000

cashback+=1; //add cashback of 1%. For gold card member additional 2% added at beginning only

tcashback=(charges*cashback*1.0)/100.0; //find total cash back

System.out.println("Cash back received is : $"+tcashback); //print total cash back

//print cash back percentage for user

if(member==1){

System.out.println("Percentage of Cash back received is : "+cashback+" % as you are Gold card member");

}else{

System.out.println("Percentage of Cash back received is : "+cashback+" %");

}

}else if(charges<50001 && charges>9999){ //check annual charges are within 10000 & 50000

cashback+=3; //add cashback of 3%. For gold card member additional 2% added at beginning

tcashback=(charges*cashback*1.0)/100.0;

System.out.println("Cash back received is : $"+tcashback);

if(member==1){

System.out.println("Percentage of Cash back received is : "+cashback+" % as you are Gold card member");

}else{

System.out.println("Percentage of Cash back received is : "+cashback+" %");

}

}else if(charges>50000){ //check annual charges is greater than 50000

cashback+=5; //add cashback of 5%. For gold card member additional 2% added at beginning

tcashback=(charges*cashback*1.0)/100.0;

System.out.println("Cash back received is : $"+tcashback);

if(member==1){

System.out.println("Percentage of Cash back received is : "+cashback+" % as you are Gold card member");

}else{

System.out.println("Percentage of Cash back received is : "+cashback+" %");

}

}

}

}