Answer to Question #259518 in C++ for Tay

Question #259518

two user defined functions to receive credit for this assignment.

Applications for mobile devices (Mobile Apps) are in great demand. You have been tasked to design an

algorithm and write a C++ program to help programmers track the sales of a Mobile App. The program

must prompt the user to input the following:

Name of mobile application

Price of a Full version download

Price of a Trial version download

Number of Full version downloads

Number of Trial version downloads

Tax Rate

The program will allow the user to calculate the total net earnings based on the price and number of

download purchases, and the tax rate. Use the following equations to calculate the total net earnings:

Gross earning total

= Price of a Full version * Number of Full version downloads

+ Price of a Trial version * Number of Trial version downloads

Tax deduction = Gross earning total * Tax Rate / 100

Total Net earnings = Gross earning total - Tax deduction

The program must output the results to the screen and to an output file named "


1
Expert's answer
2021-11-01T08:57:12-0400
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;

int main() {
    ofstream  ofs("report.dat");
    string name;
    double fullPrice;
    double trialPrice;
    int fullDownloads;
    int trialDownloads;
    double taxRate;
    double grossTotal;
    double tax;
    double netEarnings;

    cout << "Enter Apps name: ";
    getline(cin, name);
    cout << "Enter a price of a Full version download: ";
    cin >> fullPrice;
    cout << "Enter a price of a Trial version download: ";
    cin >> trialPrice;
    cout << "Enter a number of Full version downloads: ";
    cin >> fullDownloads;
    cout << "Enter a number of Trial version downloads: ";
    cin >> trialDownloads;
    cout << "Enter a tax rate: ";
    cin >> taxRate;
    cout << endl;

    cout << "Sale report for \"" << name << "\"." << endl;
    ofs << "Sale report for \"" << name << "\"." << endl;
    grossTotal = fullPrice * fullDownloads + trialPrice * trialDownloads;
    cout << "Gross earning total: $" << fixed << setprecision(2) << grossTotal << endl;
    ofs << "Gross earning total: $" << setprecision(2) << grossTotal << endl;
    tax = grossTotal * taxRate / 100;
    cout << "Tax deduction:       $"  << setprecision(2) << tax << endl;
    ofs << "Tax deduction:       $"  << setprecision(2) << tax << endl;
    netEarnings = grossTotal - tax;
    cout << "Total Net earnings:  $" << setprecision(2) << netEarnings << endl;
    ofs << "Total Net earnings:  $" << setprecision(2) << netEarnings << endl;
    
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS