Candy Sale Program
candy-v1.cpp
Download file: Windows | macOS | Unix
1// Program : Candy Sale (v.1)
2// Author : Prof. Krofchok
3// Date : Fall 2025
4// Description: This program simply reads a number from the user and redisplays
5// that number on the screen. Modules are used to break things down
6// into small pieces.
7
8#include <iostream>
9
10void input_data(int £s);
11void output_results(int pounds);
12
13int main()
14{
15 int pounds; // pounds of candy purchased
16
17 input_data(pounds);
18 output_results(pounds);
19}
20
21//
22// An input module that gets the pounds of candy purchased from the user.
23//
24void input_data(int £s)
25{
26 std::cout << "Enter pounds of truffles purchased: ";
27 std::cin >> pounds;
28}
29
30//
31// An output module that displays the pounds of truffles the user wants
32// to purchase.
33//
34void output_results(int pounds)
35{
36 std::cout << "I see that you want to purchase "
37 << pounds
38 << " pound(s) of truffles!"
39 << std::endl;
40}