Answer to Question #186063 in C++ for Shuvo

Question #186063

The following mathematical expression is used to find the number of penny stamps one gets if one inserts dollars number of dollars in a stamp vending machine that returns the change in penny stamps. Replace the given mathematical expression by a simpler expression that gives the same value. 

double amount1 = 19.35;

double amount2 = 19.95;

What are values of variables a and b after the following assignments?

 int a = amount2;

 int b = amount2 + 0.5;


1
Expert's answer
2021-05-04T07:12:43-0400
#include <iostream>


using namespace std;


int main()
{
	double amount1 = 19.35;
	double amount2 = 19.95;
	cout << "amount1 = " << amount1 << endl;
	cout << "amount2 = " << amount2 << endl;
	int a = amount2;
	int b = amount2 + 0.5;
	
	cout << "int a = 19.95 =: " << a << endl;
	cout << "int b = 19.95 + 0.5 =: " << b << endl;
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS