Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This program will reinforce our knowledge of if, while, scanf, printf, and other topics such as editing and compiling programs. In Taxiland, the tax system

This program will reinforce our knowledge of if, while, scanf, printf, and other topics such as editing and compiling programs.

In Taxiland, the tax system is scaled as follows:

If you are a government worker, you pay a flat tax of 15% of your income.

Otherwise, you pay 10% on the first $5,000, then an additional 20% on the amount over $5,000.

Unless, of course, you drive a taxi. In this case, you pay the standard taxi surcharge of $800, plus 1/3 of your taxi income. Uber has not made it there yet.

The Assignment! Your job, should you decide to accept it, is to save the country by providing an easy way to calculate the tax owed by a citizen. Your program should:

Read the amount that the worker has earned. Print an error message and exit if the amount is <= $0.

Read in the type of worker, either G for government, T for taxi driver, or O for other. Print an error message and exit if the letter is none of these.

The program should print out the amount in check format (but capitalization is not important). The program must use a function to do this printing.

Examples: Amount Prints as $123.45 one hundred twenty three dollars and forty five cents; $1,234.56 one thousand two hundred thirty four dollars and fifty six cents; $100.00 one hundred dollars and no cents

and this should work for any amount up to $99,999.99. Note that the cents are printed even if they are zero, so every answer should have and in there.

Include the C source code obviously but also a Makefile.

The program should continue to run until end-of-file is indicated. You can force the end-of-file with control-D. By the way, scanf will return the number of values that were assigned, so this is easy to check. Here is an example execution of the program.

The data you type in is in italics: What is the amount of pay? 12345.67 What is the worker type? G One thousand eight hundred fifty one dollars and eighty five cents

What is the amount of pay? 65432.10 What is the worker type? O Twelve thousand five hundred eighty six dollars and forty two cents

What is the amount of pay? 34343.43 What is the worker type? T Twelve thousand two hundred forty seven dollars and eighty one cents

The first is 15% of $12345.67. The second is $500 on the first $5,000, plus 20% of $60,432.10. The last one is $800 + $34,343.43 / 3

I would suggest using the scanf function with %d.%d as the format string. Then combine the dollars and cents into one number, like 6543210 in the middle example above.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Xxviii Special Issue On Database And Expert Systems Applications Lncs 9940

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Qimin Chen

1st Edition

3662534541, 978-3662534540

More Books

Students also viewed these Databases questions