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.
# 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;
}
Comments
Leave a comment