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

Credit Cards The Capital One credit card limits a single charge to $900 and the

ID: 3678423 • Letter: C

Question

Credit Cards

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 transaction for one month, followed by the dollar/cent values of each of the n transaction (double). Your program should compute 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).

Use either of the 3 kinds of loops: for, while, do while. Use nested loops or nested if, else if, else statements if necessary.

please write this program in java

Explanation / Answer

import java.util.Scanner;

/**
* @author Srinivas Palli
*
*/

public class CreditCardLimit {

   public static void main(String[] args) {
       // TODO Auto-generated method stub

       Scanner scanner = null;
       try {

           int numberOfTransactions;
           double sumOfTransactions = 0, transactionAmount;
           scanner = new Scanner(System.in);
           System.out.print("Enter the number of transaction for one month :");
           numberOfTransactions = scanner.nextInt();

           for (int i = 1; i <= numberOfTransactions; i++) {

               System.out.print("Enter the Amount of Transaction " + i
                       + " : $");
               transactionAmount = scanner.nextDouble();
               sumOfTransactions += transactionAmount;

               if (transactionAmount > 900) {

                   System.out.println("Transaction Exceeds $900");
               }

           }

           if (sumOfTransactions > 3000) {

               System.out.println("Month Transactions Exceeds $3000");
           }
           System.out.println("Total Amount of Month Transactions :$"
                   + sumOfTransactions);

       } catch (Exception e) {
           // TODO: handle exception
       } finally {

           scanner.close();
       }

   }

}

OUTPUT:


Enter the number of transaction for one month :5
Enter the Amount of Transaction 1 : $265
Enter the Amount of Transaction 2 : $300
Enter the Amount of Transaction 3 : $950
Transaction Exceeds $900
Enter the Amount of Transaction 4 : $600
Enter the Amount of Transaction 5 : $350
Total Amount of Month Transactions :$2465.0

Enter the number of transaction for one month :5
Enter the Amount of Transaction 1 : $265
Enter the Amount of Transaction 2 : $358
Enter the Amount of Transaction 3 : $950
Transaction Exceeds $900
Enter the Amount of Transaction 4 : $1500
Transaction Exceeds $900
Enter the Amount of Transaction 5 : $1000
Transaction Exceeds $900
Month Transactions Exceeds $3000
Total Amount of Month Transactions :$4073.0

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