The Capital one credit card limits a single charge to $900 and the total monthly
ID: 3650861 • Letter: T
Question
The Capital one credit card limits a single charge to $900 and the total monthly charges to $3000. Write a program that accepts an integer n representing the number of transactions for one month, followed by the dollar/cent values of each of the n transactions (double). Your program should computer and print the minimum, maximum and sum of all transactions for the month. If you exceed either limit ( a single transaction over $900, or total over $3000) then the program displays the appropriate message(s).Explanation / Answer
Please rate...
Program CreditCard.java
==================================================
import java.util.Scanner;
class CreditCard
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
System.out.print("Enter the number of transactions: ");
int n=s.nextInt();
int i;
double min=900,max=0,sum=0;
for(i=1;i<=n;i++)
{
System.out.print("Value of Transaction #"+i+" in dollars: ");
double a=s.nextDouble();
if(a>900)System.out.println("You have exceeded the credit limit of $900");
if(a<min)min=a;
if(a>max)max=a;
sum=sum+a;
if(sum>3000)System.out.println("You have exceeded the total monthly charge of $3000");
}
System.out.println("The minimum charge is: $"+min);
System.out.println("The maximum charge is: $"+max);
System.out.println("The total monthly charge is: $"+sum);
}
}
===================================================
Sample output: