to calculate the petrol cost with any values using c++
1
Expert's answer
2012-08-10T09:38:08-0400
#include <iostream> using namespace std; int main() { // initializing the variables: int productID = 0; const float priceList [] = {0.85f, 1.10f, 1.35f}; float amount; float total = 0.0f;
// getting the data from user: while (productID < 1 || productID > 3) { cout << "Please enter the petrol type ID (1, 2, 3): " << endl; cin >> productID; } cout << "Please enter the amount of petrol needed: " << endl; cin >> amount;
// calculating the petrol cost: total += amount * priceList [productID - 1];
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment