Answer to Question #297276 in C++ for Rajen

Question #297276

develop a c++ program to create a cake class. include two public fields that contain the price of the cake and the calorie count of the cake. write a main () function that declares a cake object. prompt the user for field values. print the values, and then display the cost per calorie.

1
Expert's answer
2022-02-13T09:42:52-0500
# include <iostream>


class Cake {
public:
	double price;
	double calories_count;
};


int main(void) {
	std::cout.setf(std::ios::fixed);


	Cake example;


	std::cout << "Printing the price of the cake ";
	std::cin >> example.price;
	std::cout << "Printing the count of calories in the cake ";
	std::cin >> example.calories_count;
	std::cout << "Price of the cake is " << example.price;
	std::cout << "\nCount of calories in the cake is " << example.calories_count;
	std::cout << "\nPrice per calories is " << example.price / example.calories_count;
}

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