Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the C language I need the following code with the following restrictions (my professor requires us to work through repl.it if that makes this

In the C language I need the following code with the following restrictions (my professor requires us to work through repl.it if that makes this easier for you):

Have a program that asks for a user inputted number (positive or negative) and then have the program output that number in US currency format. With a negative sign (if the value entered is negative), a dollar sign, the number with appropriate commas in the hundreds positions, and two character spaces after the decimal point for change. So if the user inputs the value 123456789.12, the program should output: $123,456,789.12

The example output should look like this:

-----------------------------------------------------------------

Please enter an amount: (user inputted amount)

(program outputted amount in currency format)

-----------------------------------------------------------------

Below are the rules for how the program should be written:

  • You must use a double (or long double) in your scanf for your currency
    • Using a double or long double for most of your variables, calculations, and functions is advised.
  • Any range of numbers is fair game, your program cannot hardcode for ranges or thousands
    • You must utilize logarithmic function(s) to calculate power/length
    • You must utilize the power/length you calculate
    • You must utilize power function(s) to calculate and print each digit separately except after the decimal point
      • *hint: loop
    • You must utilize a ternary at some point for the negative sign.
  • You must write and use at minimum 2 user-defined functions
  • All functions must have valid return types and valid arguments. Ex. int main() will not be accepted.
  • Use of global variables is prohibited.
  • All functions (excluding main) must the declared and defined separately.
    • All functions should have clear valid names shortly describing their purpose
  • All variables must be declared and initialized at the top of the function they are used in.
    • All variables, constants, and parameters should have clear valid names shortly describing their purpose
  • Only a single return is allowed per function, a return per function is also required.
    • No other jumps are allowed (no break, goto, continue, etc.) except for necessary break statements in switch cases.
  • if, else, while, do-while, and for blocks/loops need to have curly braces - no single line/statement usage

Thank you for your help.

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2018 Dublin Ireland September 10 14 2018 Proceedings Part 1 Lnai 11051

Authors: Michele Berlingerio ,Francesco Bonchi ,Thomas Gartner ,Neil Hurley ,Georgiana Ifrim

1st Edition

3030109240, 978-3030109240

More Books

Students also viewed these Databases questions