answersLogoWhite

0

#include<iostream>

#include<sstream>

double enter_number (std::string& prompt)

{

double result {};

std::string input {};

while (1)

{

std::cout << prompt;

std::cin >> input;

std:stringstream ss;

ss << input;

if (ss >> result)

break;

std::cerr << "Invalid input: " << input << std::endl;

}

return result;

}

int main()

{

double amount, tax_rate, tax, total, ;

amount = enter_number ("Enter amount ($): ");

tax_rate = enter_number ("Enter tax rate (%): ");

tax = amount * tax_rate;

total = amount + tax;

std::cout << "Tax ($): " << tax << std::endl;

std::cout << "Total ($): " << total << std::endl;

}

User Avatar

Wiki User

10y ago

What else can I help you with?

Related Questions

How do you Open a text file as C plus plus source code?

All C++ source code is is a text file with the .cpp extension. So if you save your code as *****.cpp then it is automatically C++ source code.


Source code of DSR and AODV in C plus plus?

code source de dsr sous omnet++4.1 en .cc


What is a source code file in c plus plus?

A source code file is a plain-text file containing C++ instructions. The instructions must be compiled and linked to create a native machine code executable.


How do you write the number 4 using only the number 3?

As a calculation you could have 3 divided by 3 plus 3.


How can i write pseudo code for C plus plus if i haven't even wrote the program yet?

You are going about this backwards. First, define the program. Second, describe its algorithm. Third, if needed, write pseudo code. (Sometime, algorithm and pseudo code is the same process.) Fourth, or third, write real code.


What is the differentiate of turbo c from turbo c plus plus?

Turbo C compiles c source. turbo c++ compiles c++ source code.


A c plus plus code name sumcpp saved on a diskis it process or job?

It is neither. It is a source file.


Where do you get c plus plus software?

A good open source IDE for C++ would be Code::Blocks or Notepad++.


Write a c plus plus code that insert a node in the middle everywhere?

Use std::list::insert_before().


Can anyone provide me a executable C or C plus plus language source code for netstat in Windows XP environment?

Netstat for Windows is provided by Microsoft itself, so you're unlikely to find any source code for it. However you may find Linux versions of Netstat source code available. The functionality may differ to some extent, but how useful they are will depend on why you need the source code in the first place.


What do you mean by running of a program in c plus plus?

In order to run a C++ program the program must be compiled and linked to create an executable. It is the executable that actually runs, not the source code. The source code is simply the human-readable code the compiler requires to generate object code for the linker which produces the machine-readable code. However, when the executable is executed within a debugging environment, we can set breakpoints in the source code and step through the source code just as if the source itself were executing, as would be the case if C++ were an interpreted language. Unlike an interpreted language where we can change the source code and see the results immediately, the source code (or at least the portion that has changed) must be recompiled to accommodate the changes.


How to write a code for finding sum of left diagonals elements in an array using c plus plus?

truzi i Ghal