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

A bank charges a base fee of $10 per month, plus the following check fees for a

ID: 3670950 • Letter: A

Question

A bank charges a base fee of $10 per month, plus the following check fees for a commercial checking account:

$.10 each for less than 20 checks

$.08 each for 20-39 checks

$.06 each for 40-59 checks

$.04 each for 60 or more checks.

Write a program that asks for the number of checks written for the month. The program should then calculate and display the bank's service fees for the month.

B)

Write a program that asks the user to enter three names, and then displays the names sorted in ascending order. For example, if the user entered in "Charlie", "Leslie", and "Andy", the program would display:

Andy

Charlie

Leslie

Explanation / Answer

#include<iostream>
using namespace std;
double get_balance()
{
double balance;
cout << "What is your account's balance?" << ' ';
cin >> balance;
return balance;
}
int get_checks_written()
{
int checks_written;
cout << "How many checks did you write?" << ' ';
cin >> checks_written;
return checks_written;
}
double compute_charges(double balance, int checks_written)
{
double fees = 0;
if(balance < 400)
{
fees = fees + 15;
}
if(checks_written < 20)
{
fees = fees + 0.1 * checks_written;
}
else if(checks_written < 40)
{
fees = fees + 0.08 * checks_written;
}
else if(checks_written < 60)
{
fees = fees + 0.06 * checks_written;
}
else
{
fees = fees + 0.04 * checks_written;
}
return fees;
}
int main()
{
double balance = get_balance();
int checks_written = get_checks_written();
double charges;
if(checks_written < 0)
{
cout << "Cannot accept a negative number of checks written. " <<"The transaction will not complete." << ' ';
}
else
{
if(balance < 0)
{
cout << "Warning: your account is overdrawn." << ' ';
}
charges = compute_charges(balance, checks_written);
cout << "Service fees: $" << charges << ' ';
}
return 0;
}

b)

public class SortNames
{
public static void main(String [] args)
{
String name1, name2, name3, firstPlace = null, secondPlace = null, thirdPlace = null;
name1 = JOptionPane.showInputDialog("Please enter a persons name:");
name2 = JOptionPane.showInputDialog("Now enter a second name:");
name3 = JOptionPane.showInputDialog("Now enter a third name:");
if (name1.compareToIgnoreCase(name2) < 0)
{
if (name1.compareToIgnoreCase(name3) < 0)
firstPlace = name1;
else
{
firstPlace = name3;
JOptionPane.showMessageDialog(null, "first place is " + firstPlace);
}
}
else
JOptionPane.showMessageDialog(null, "this is dumb");
}
}

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