LOTTO - Programming Logic and Design Programming Logic and Design, Comprehensive
ID: 3591209 • Letter: L
Question
LOTTO - Programming Logic and Design
Programming Logic and Design, Comprehensive
Program Life Cycle (Industry way)
1. Analyzing the problem
2. Design the Flowchart logic
3. Write the Code
4. Test and debug the program
Your assignment will allow you to apply your knowledge of logic syntax, understanding a program problem, and its development cycle,
This PROBLEM is based on concepts for Data, Modules, and Designing a Program, and If statements.
Write a Simple Sequence program using only step #1 & #2 of the Program Development Life Cycle (Analyze the problem and Design Flowchart) to solve the following problem.
The user must pick three numbers.
Display the picked numbers using a format shown below. The # represents one of the three numbers.
Only submit step #1 - Analyze the problem and step #2 - Flowchart.
Bonus points will be given for all four steps based upon no errors on step #2.
Step #1:
State the problem as given
List the variables ......... and the description of the variable
Identify the Data File
Step #2:
Use a minimum of three modules
Declare all variables
user must enter there three numbers
Test the user input to see if the numbers are winning numbers (i.e. use the IF statement)
Write appropriate message for winning and losing.
Do not use a loop,
When drawing the ball symbols, just treat the image as being drawn line-by-line. Example:
|* *| Line #1| _ | Line #2
This is a simple square robot happy face being displayed on screen or on a paper, then you will code the following
Write "| * * |"Write "| --- |"
Explanation / Answer
include <string>
#include <iostream>
using namespace std;
class Position {
public:
Position(const string& aTitle, double aSalary)
: title(aTitle), salary(aSalary) {}
const string& getTitle() const { return title; }
double getSalary() const { return salary; }
void changeSalaryTo(double d) { salary = d; }
void display(ostream& os = cout) const {
os << '[' << title << ',' << salary << ']';
}
private:
string title;
double salary;
}; // class Position
class Entry {
public:
Entry(const string& aName, unsigned aRoom, unsigned aPhone,
Position& aPosition)
: name(aName), room(aRoom), phone(aPhone), pos(&aPosition) {
}
void display(ostream& os = cout) const {
os << name << ' ' << room << ' ' << phone << ", ";
pos->display(os);
}
const string& getName() const { return name; }
const unsigned& getPhone() const { return phone; }
private:
string name;
unsigned room;
unsigned phone;
Position* pos;
}; // class Entry
class Directory {
public:
void add(const string& name, unsigned room, unsigned ph, Position& pos) {
if (size == capacity) {
// something is missing!!! Add it!
} // if
entries[size] = new Entry(name, room, ph, pos);
++size;
} // add
void display(ostream& os = cout) const {
for (size_t i = 0; i < size; ++i) {
entries[i]->display(os);
os << endl;
}
}
private:
Entry** entries = nullptr;
size_t size = 0;
size_t capacity = 0;
}; // class Directory
void doNothing(Directory dir) { dir.display(); }
int main() {
// Note that the Postion objects are NOT on the heap.
Position boss("Boss", 3141.59);
Position pointyHair("Pointy Hair", 271.83);
Position techie("Techie", 14142.13);
Position peon("Peonissimo", 34.79);
// Create a Directory
Directory d;
d.add("Marilyn", 123, 4567, boss);
d.display();
Directory d2 = d; // What function is being used??
d2.add("Gallagher", 111, 2222, techie);
d2.add("Carmack", 314, 1592, techie);
d2.display();
cout << "Calling doNothing ";
doNothing(d2);
cout << "Back from doNothing ";
Directory d3;
d3 = d2;
// Should display 1592
cout << d2["Carmack"] << endl;
} // main
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.