Question

Please include the answer to both questions in a single file. Ensure the file you submit...

Please include the answer to both questions in a single file. Ensure the file you submit has the extension .cpp.

Write a complete C++ program that does the following:

1. Declare two variables, checking and savings, of type double. Prompt the user for the amount in both accounts. If the total of both accounts is less than or equal to zero, output "Bankrupt". If the total of both accounts is greater than 250000, output "Money Bags". If neither of these is the case, simply output "Total: " followed by the total in both accounts.

2. Declare a variable of type int. Prompt the user for a positive three-digit number. Test to ensure the number is within the proper bounds. If the number is larger or less than three digits, output "Error" and terminate the program. Otherwise, calculate and print the sum of the three digits.

Examples
Question 1:

Checking: -5 Savings: 3 Bankrupt

Question 2:

Enter a positive three-digit number: 491 14

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>

using namespace std;


int main(){
   double checking,savings;
   cout<<"Enter total amount in checking and savings accounts: ";
   cin>>checking;
   cin>>savings;
   if((checking+savings)<=0)
       cout<<"Bankrupt";
   else if((checking+savings)>250000)
       cout<<"Money Bags";
   else
       cout<<"Total : "<<checking<<" , "<<savings;
  
}

Answer 2:

#include <iostream>

using namespace std;

int main(){
   int n,sum=0;
   cout<<"Enter 3 digit number: ";
   cin>>n;
   if(n>=100 && n<1000){
       sum+=n%10;
       n=n/10;
       sum+=n%10;
       n=n/10;
       sum+=n%10;
       cout<<"Sum of digits: "<<sum;
   }
   else{
       cout<<"Error: Invalid Input";
   }
}

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me

Add a comment
Know the answer?
Add Answer to:
Please include the answer to both questions in a single file. Ensure the file you submit...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In C++ please! Please include .cpp and .hpp files! Thank you! Recursive Functions Goals Create and...

    In C++ please! Please include .cpp and .hpp files! Thank you! Recursive Functions Goals Create and use recursive functions In this lab, we will write a program that uses three recursive functions. Requirements: Important: You must use the array for this lab, no vectors allowed. First Recursive Function Write a function that recursively prints a string in reverse. The function has ONLY one parameter of type string. It prints the reversed character to the screen followed by a newline character....

  • Programming Concepts CS 225 for C++ To make telephone numbers easier to remember, some companies use...

    Programming Concepts CS 225 for C++ To make telephone numbers easier to remember, some companies use digits and letters (or only letters) to show their telephone number. In some cases, to make a telephone number meaningful, companies might use more than seven digits and letters. Here are some examples: Phone Number in Display Note Actual Phone Number GET LOAN - 438-5626 CALL HOME More than seven digits/letters used for ease of remembrance. 225-5466 111 GOLD - 111-4653 Glass4u - 452-7748...

  • C++ Loops homework Prompt the user for a desired password, input the password. Your program may...

    C++ Loops homework Prompt the user for a desired password, input the password. Your program may assume without checking that there is no input failure and that the password contains no white space. Let's say the rules for a legal password are: # chars must be in [4, 8] # digs must be >= 2 The password must contain at least one letter of each case The password must contain at least one char that's not a letter or digit...

  • Write C++ Code in single source file (.cpp file) containing following user defined functions: 1. IsEven-...

    Write C++ Code in single source file (.cpp file) containing following user defined functions: 1. IsEven- takes an integer input (one argument of type int) and return true or false. 2. IsPositive- takes a float input (one argument of type double) and return a Boolean value. The function returns the true if its argument is positive and false if its argument is zero or negative. 3. IsPrime- takes an integer input and return true or false. 4. NumOfDigits- takes an...

  • Write a program that calculates the average number of days a company's employees are absent during the year and outputs a report on a file named "employeeAbsences.txt".

    Project DescriptionWrite a program that calculates the average number of days a company's employees are absent during the year and outputs a report on a file named "employeeAbsences.txt".Project SpecificationsInput for this project:the user must enter the number of employees in the company.the user must enter as integers for each employee:the employee number (ID)the number of days that employee missed during the past year.Input Validation:Do not accept a number less than 1 for the number of employees.Do not accept a negative...

  • In Matlab Create a single script (.m file) to solve these problems. Unless directed otherwise, use...

    In Matlab Create a single script (.m file) to solve these problems. Unless directed otherwise, use meaningful variable names for each variable; do not use the default variable ans to store your results. For this project, suppress your output with semi-colons (;). Each problem should be in a separate cell, using the cell mode feature of MATLAB. Problem 4 Video games are rather complicated to program, not least of which because of the graphics work that needs to be completed...

  • Please do not copy other solution from the site as they never fully implement all the...

    Please do not copy other solution from the site as they never fully implement all the listed guidelines below. Please write a shell script called atm.bash similar to the ones used in ATM machines. Essentially your script is to handle a person's savings and checking accounts and should handle the following services:             Transfer from savings account to checking account             Transfer from checking account to savings account             Cash withdrawal from either account             Balance statements for both the...

  • c++ The program will be recieved from the user as input name of an input file...

    c++ The program will be recieved from the user as input name of an input file and and output.file. then read in a list of name, id# and score from input file (inputFile.txt) and initilized the array of struct. find the student with the higher score and output the students info in the output file obtain the sum of all score and output the resurl in output file. prompt the user for a name to search for, when it find...

  • In this assignment you’re going to write a complete C program that opens a file “digits.txt”,...

    In this assignment you’re going to write a complete C program that opens a file “digits.txt”, inputs the values, and analyzes these values to see if they follow Benford’s law. In particular, your program analyzes the first digit of each input value, and outputs: 1. The total # of input values N 2. The counts for each digit: # of values that start with 1, # of values that start with 2, etc. 3. A histogram of the counts for...

  • please use c++ programming and single dimensional arrays to solve this problem thank you Problem 02:...

    please use c++ programming and single dimensional arrays to solve this problem thank you Problem 02: Large Integer (20 points) In CH, the largest int value is 2147483647. So, an integer larger than this cannot be stored and processed as an integer. Similarly, if the sum or product of two positive integers is greater than 2147483647, the result will be incorrect. One way to store and manipulate large integers is to store each individual digit of the number in an...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT