Question

COMP 1120 Project One - Part One Assigned: September 18, 2019 Due! September 30, 2019 * Part Two will be due on October 2 The
COMP 1120 Proiect One - Part Two Assigned: September 25, 2019 Duet October 2, 2019 Modify your completed program for Project
0 0
Add a comment Improve this question Transcribed image text
Answer #1

C++ PROGRAM

/******************************************************************************
FileName: auhorPay2.cpp
*******************************************************************************/

#include <iostream>
#include <iomanip>
using namespace std;

//prototype
double calculateAuthorPay(int , int );

//main function
int main()
{
int storyLengthInWords;
char authorLevel;
double authorPay = 0,largestAmountPaid = 0, runningSumOfAmountPaid = 0;
double averagePay;
int totalCounter = 0,counterA = 0,counterB = 0,counterC= 0;
  
//start do-while loop
do
{
cout<<endl<<"Enter length of story (in words): ";
cin>>storyLengthInWords; //read length of story in words
//if length entered is -1 breaks out of do-while
if(storyLengthInWords == -1)
{
break;
}
cout<<endl<<"Enter the level of the author: ";
cin>>authorLevel;//read level of author
  
totalCounter++; //increase total counter
  
//increase counter of individuallevel based on author level
if(authorLevel=='A' || authorLevel=='a')
{
counterA++;
}
else if(authorLevel == 'B' || authorLevel =='b')
{
counterB++;
}
else if(authorLevel =='C' || authorLevel =='c')
{
counterC++;
}
  
//calculate author pay
authorPay = calculateAuthorPay(storyLengthInWords,authorLevel);
  
//print length and authorPay
cout<<endl<<"Length of Story (words): "<<storyLengthInWords;
cout<<endl<<"Amount Due Author: "<<"$"<<setprecision(2)<<fixed<<authorPay;
  
//calculate running sum
runningSumOfAmountPaid = runningSumOfAmountPaid + authorPay;
  
//calculate largest pay
if(authorPay > largestAmountPaid){
largestAmountPaid = authorPay;
}
  
cout<<endl;
  
}while(true);
  
  
//calculate average pay
averagePay = runningSumOfAmountPaid / totalCounter;
  
//print details
cout<<endl<<"The total number of payments calculated : "<<totalCounter;
cout<<endl<<"The number of payments made for author level A: "<<counterA;
cout<<endl<<"The number of payments made for author level B: "<<counterB;
cout<<endl<<"The number of payments made for author level C: "<<counterC;
cout<<endl<<"The average amount paid for a story: "<<"$"<<setprecision(2)<<averagePay;
cout<<endl<<"The largest amount paid for a story: "<<"$"<<setprecision(2)<<largestAmountPaid;
  
return 0;
}

//Fucntion: calculateAuthorPay
//The method calculated Author pay based on the length(in words)
//and the level of the author
//Input: int lengthInWords, int authorLevel
//Output: double finalPay
double calculateAuthorPay(int lengthInWords, int authorLevel)
{
double totalPay = 0, finalPay;
  
  
//calculation logic
if(lengthInWords < 7500)
{
totalPay = lengthInWords * 0.08; //rate = $0.08 per workd
}
else if(lengthInWords>= 7500 && lengthInWords<8000)
{
totalPay = 600; //fixed rate of $600
}
else if(lengthInWords>=8000 && lengthInWords<17500)
{
totalPay = lengthInWords * 0.075; //rate = $0.075 per word
}
else if(lengthInWords>=17500 && lengthInWords<19000)
{
totalPay = 1313; //fixed rate of $1313
}
else //lengthInWords >=19000
{
totalPay = lengthInWords * 0.07; //rate = $0.07 per word
}
  
//final pay based on author level
if(authorLevel =='C' || authorLevel =='c')
{
finalPay = totalPay;
}
else if(authorLevel =='B' || authorLevel =='b')
{
finalPay = totalPay * 1.25; //1.25 times of pay for level C
}
else if(authorLevel == 'A' || authorLevel =='a')
{
finalPay = totalPay * 1.75;//1.75 times of pay for level C
}
  
return finalPay;
}

==================================

OUTPUT

===================================


Enter length of story (in words): 18500

Enter the level of the author: C

Length of Story (words): 18500
Amount Due Author: $1313.00

Enter length of story (in words): 21589

Enter the level of the author: C

Length of Story (words): 21589
Amount Due Author: $1511.23

Enter length of story (in words): 12689

Enter the level of the author: B

Length of Story (words): 12689
Amount Due Author: $1189.59

Enter length of story (in words): 15897

Enter the level of the author: B

Length of Story (words): 15897
Amount Due Author: $1490.34

Enter length of story (in words): 22365

Enter the level of the author: A

Length of Story (words): 22365
Amount Due Author: $2739.71

Enter length of story (in words): 11568

Enter the level of the author: A

Length of Story (words): 11568
Amount Due Author: $1518.30

Enter length of story (in words): -1

The total number of payments calculated : 6
The number of payments made for author level A: 2
The number of payments made for author level B: 2
The number of payments made for author level C: 2
The average amount paid for a story: $1627.03
The largest amount paid for a story: $2739.71

Add a comment
Know the answer?
Add Answer to:
COMP 1120 Project One - Part One Assigned: September 18, 2019 Due! September 30, 2019 *...
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
  • Program In Assembly For this part, your MAL program must be in a file named p5b.mal....

    Program In Assembly For this part, your MAL program must be in a file named p5b.mal. It must have at least one function in addition to the main program. For the purposes of Part (b), you may assume the following 1. Any line of text typed by a user has at most 80 characters including the newline character. 2. A whitespace character refers to a space, a tab or the new line character. 3. A word is any sequence of...

  • MECH 227 Spring 2019 Comp. Project 1 Due: April 22, 2019 Problem 1.3 As part of a design calculat...

    Can someone do number one and 2a MECH 227 Spring 2019 Comp. Project 1 Due: April 22, 2019 Problem 1.3 As part of a design calculation, you must evaluate an enthalpy change for an obscure organic vapor that is to be cooled from 1800 °C to 150 °C in a heat ezchanger. You search through all the standard references for tabulated enthalpy or heat capacity dato for the vapor but have no luck at all until you finally stumble on...

  • I need all parts with MATLAB programming .i have part A already 3. Speed Reader (Adapted...

    I need all parts with MATLAB programming .i have part A already 3. Speed Reader (Adapted from http://ni stanford.edu/2015 /poser a-s -reader This project requires you to create a program that takes two inputs: o A string of any length. o A number of words per minute. Your program will take the string, break it up into individual words, and display it one word at a time at the desired rate. For instance, "Hello World!" at 500 words per minute...

  • EI E 237 Assignment 4: Python Program Due September 18, 2018 Description For this assignment, you...

    EI E 237 Assignment 4: Python Program Due September 18, 2018 Description For this assignment, you will practice several basic Python programming skillis by writing a simple Python 3 program. This program will implement a text-based, 2-player rock-paper-scissors game (if you are unfamiliar with rock-paper-scissors, check out the Wikipedia article The program should give some brief instructions to the players. Next, it should prompt player for a choice, then prompt player 2 for a choice. If a player inputs something...

  • Please use the Schedule C, Form 1120,year 2019. The attached information is to be used to complete Part A (Schedule C)...

    Please use the Schedule C, Form 1120,year 2019. The attached information is to be used to complete Part A (Schedule C) and Project B (1120-page 1 and schedule m-1). This project is to be done manually (i.e. no software). Basic information is provided for a single business. Essentially this requires you to first complete a Schedule C for a proprietorship and then use the same data to complete a form 1120 for a corporation. A trial balance is posted in...

  • Language : JAVA Part A Create a class CompanyDoc, representing an official document used by a...

    Language : JAVA Part A Create a class CompanyDoc, representing an official document used by a company. Give it a String title and an int length. Throughout the class, use the this. notation rather than bare instance variables and method calls.   Add a default constructor. Add a parameterized constructor that takes a value for title. Use this( appropriately to call one constructor from another. Add a toString(), which returns a string with the title, and the length in parentheses. So...

  • This project is meant to give you experience writing linked lists and graphs. As such, you...

    This project is meant to give you experience writing linked lists and graphs. As such, you are not permitted to use arrays or any data structure library. You may, however, make use of code presented in class and posted to Blackboard. Objective Your goal for this project is to take a block of text, analyze it, and produce random sentences in the style of the original text. For example, your program, given Wizard of Oz, might produce: how quite lion...

  • For this lab you will write a Java program that plays a simple Guess The Word...

    For this lab you will write a Java program that plays a simple Guess The Word game. The program will prompt the user to enter the name of a file containing a list of words. These words mustbe stored in an ArrayList, and the program will not know how many words are in the file before it starts putting them in the list. When all of the words have been read from the file, the program randomly chooses one word...

  • QUESTIONS 13-18 PLEASE! Maximum Storage Area DUE DATE: This project is worth 10% of your Unit...

    QUESTIONS 13-18 PLEASE! Maximum Storage Area DUE DATE: This project is worth 10% of your Unit 2 grade. Please review the Project FAQ handout for format and process. Problem Situation A construction company wishes to build a rectangular enclosure to store machinery and equipment. The site selected borders on a river that will be used as one of the sides of the rectangle. Fencing will be needed to form the other three sides. The company foot high chain-link fencing. The...

  • in c++ please Page 1 of 3 (PRO) Project Assignment Instructions Last Charged: 6/1/2020 Read and...

    in c++ please Page 1 of 3 (PRO) Project Assignment Instructions Last Charged: 6/1/2020 Read and follow the directions below carefully and perform the steps in the order listed. You will be solving one program as instructed and turning in your work electronically via an uploaded file within Eagle Online/Canvas and copy & paste the program to the Text Entry box as well. Make sure and check your work prior to uploading the assignment (NOTE: For Steps 1 & 2...

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