Question

Create two classes and name their types HotdogStand and Money • All relevant classes, functions, and...

Create two classes and name their types HotdogStand and Money
• All relevant classes, functions, and data shall be placed in a namespace called MyAwesomeBusiness
• Negative amounts of Money shall be stored by making both the dollars and cents negative
• The Money class shall have four (4) constructors
– A default constructor that initializes your Money object to $0.00
– A constructor that takes two integers, the first for the dollars and the second for the cents
– A constructor that takes one integer, for an clean dollar amount
– A constructor that takes one double, and can assign dollars and cents accordingly
• int getPennies() const
– Returns the equivalent amount of money as a number of pennies
• bool isNegative() const
– Returns true if your amount of money is negative
• void add(const Money &m)
– The sum shall be stored in the calling object
• void subtract(const Money &m)
– The difference shall be stored in the calling object
• bool isEqual(const Money &m) const
void print() const
– This function prints the amount of Money you have; it must print a ‘$,’ and always show two decimal
places
– Negative amounts of Money shall be represented in the following manner: ($X.XX)
• The Money class shall have two private data members
– An integer that represents how many dollars you have.
– An integer that represents how many cents you have.
HotDogStand Class Requirements
• The HotdogStand class shall have two (2) constructors
– A default constructor that initializes your HotdogStand object with no cash, a price of $3.50, and no
hotdogs sold
– A constructor that takes a double, and initializes your HotdogStand object with no cash, the provided
hotdog price, and not hotdogs sold
• const Money getCash() const
– This returns the total cash the HotdogStand has
• const Money getPrice() const
• int getDogsSold() const
– This returns the number of hotdogs sold by the stand
• const Money getStandRevenue() const
– This calculates the total money made by selling hotdogs
• void setPrice(double price)
• void sellHotdog()
– Increments all appropriate data members accordingly
• static int getNumStands()
• static int getTotalHotdogsSold()
• static const Money getTotalRevenue()
• The HotdogStand class shall have six (6) private data members
– A Money object that will represent how much money the stand has made
– A Money object that will represent the price of a hotdog
– An integer that will describe how many hotdogs a stand has sold
– A static integer that represents the total number of HotdogStand objects
– A static integer that represents the total number of hotdogs sold
A static Money object that represents total revenue for all HotdogStand objects
Non-Member Requirements
• Define the following non-member variable:
– HotdogStand franchises[10]
• Define the following non-member function:
– void printRundown(const HotdogStand franchises[], int num)
* This function will print the summary that is shown in the sample run below
main() Requirements
• The end-user shall be prompted for how many hotdog stands they own
• The end-user will then be prompted for how many of those hotdog stands sell fancy hotdogs
• If the above input is greater than zero (0), the end-user shall be prompted for the price of the fancy hotdogs
– The end-user may type the price with or without the $
• The simulation is then run and the output is printed to the screen
Simulation Requirements
• The simulation only runs through a single day
• The last n stands are always fancy, where n is the number of stands designated as fancy by the end-user
• Regular hotdog stands can sell a random number in the range 20 - 60 (inclusive) hotdogs a day
• Fancy hotdog stands can sell a random number in the range 1 - 30 (inclusive) hotdogs a day

0 0
Add a comment Improve this question Transcribed image text
Answer #1

I have written the program in C# langauge:

namespace MyAwesomeBusiness
{
class Money
{
private int _dollar = 0;
private int _cent = 0;
public double _Money { get; set; }
public Money()
{
_Money = 0.00;
}
public Money(int dollar,int cent)
{
_dollar = dollar;
_cent = cent;
_Money = dollar + cent;
}
public Money(double money)
{
_dollar = Convert.ToInt32(Math.Truncate(_Money));
_cent = Convert.ToInt32(Math.Truncate(_Money));
_Money = money;
}
//As we know 1 Pennies=1 $
int getPennies()
{
int NoofPennies = Convert.ToInt32 (Math.Truncate(_Money));
return NoofPennies;
}
bool isNegative()
{
if (_Money >= 0)
{
return false;
}
else
return true;
}
void add(Money Money)
{
_Money = _Money + Money._Money;
}
void subtract(Money Money)
{
_Money = _Money - Money._Money;
}
bool isEqual(Money Money)
{
if (_Money == Money._Money)
{
return true;
}
else
return false;
}
void print()
{
if (_Money >= 0)
Console.WriteLine("$" + String.Format("{0:0.00}", _Money));
else
Console.WriteLine("$X.XX");
}

}

}

-----------------

namespace MyAwesomeBusiness
{
class HotdogStand
{
public static int NpPFHotdogStand = 0;
public static int hotdogsSold = 0;
public static Money TotalMoney = new Money();
private Money _Cash = new Money();
private Money _HotDogPrice = new Money();
private int _NoOfHotDogsold = 0;

public HotdogStand()
{
_Cash = new Money();
_HotDogPrice = new Money(3.50);
_NoOfHotDogsold = 0;
}
public HotdogStand(double value)
{
_Cash = new Money();
_HotDogPrice = new Money(value);
_NoOfHotDogsold = 0;
}
public Money getCash()
{
return _Cash;
}
public Money getPrice()
{
return _HotDogPrice;
}
public int getDogsSold()
{
return _NoOfHotDogsold;
}
public void setPrice(double price)
{
_HotDogPrice._Money = price;
}
public void sellHotdog()
{
_Cash._Money = _HotDogPrice._Money+_Cash._Money;

}
public static int getTotalHotdogsSold()
{
return hotdogsSold;
}
public static Money getTotalRevenue()
{
return TotalMoney;
}


}
}

--------------------Program.cs----------

static void Main(string[] args)
{
HotdogStand[] franchises=new HotdogStand[10];

Console.WriteLine("enter the HotDog Stands which you own?");
int NoOfStand = Convert.ToInt32(Console.ReadLine());
HotdogStand.NpPFHotdogStand = NoOfStand;
Console.WriteLine("how many of those hotdog stands sell fancy hotdogs?");
int NoOfStandSellHotdog = Convert.ToInt32(Console.ReadLine());
if (NoOfStandSellHotdog > 0)
{
Console.WriteLine("enter the Price of hot dog");
string price = Console.ReadLine();
price= price.Replace("$", "");
//Simulation
HotdogStand objHotdogStand = new HotdogStand();
objHotdogStand.setPrice(Convert.ToDouble(price));
for (int i = 0; i < 10; i++)
{ //regular hot dog
objHotdogStand.sellHotdog();
}
Console.WriteLine(objHotdogStand.getDogsSold());
Console.WriteLine(objHotdogStand.getPrice());

}
Console.ReadLine();
}

Thanks

Add a comment
Know the answer?
Add Answer to:
Create two classes and name their types HotdogStand and Money • All relevant classes, functions, and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create this c++ program. Create to classes and name their type Account and Money. Follow the...

    Create this c++ program. Create to classes and name their type Account and Money. Follow the instruction listed below. Please read and implement instructions very carefully Money Class Requirements - Negative amounts of Money shall be stored by making both the dollars and cents negative The Money class shall have 4 constructors * A default constructor that initializes your Money object to $0.00 A constructor that takes two integers, the first for the dollars and the second for the cents...

  • implement a class called PiggyBank that will be used to represent a collection of coins. Functionality...

    implement a class called PiggyBank that will be used to represent a collection of coins. Functionality will be added to the class so that coins can be added to the bank and output operations can be performed. A driver program is provided to test the methods. class PiggyBank The PiggyBank class definition and symbolic constants should be placed at the top of the driver program source code file while the method implementation should be done after the closing curly brace...

  • Here are the files I've made so far: /********************* * File: check05b.cpp *********************/ #include &lt...

    Here are the files I've made so far: /********************* * File: check05b.cpp *********************/ #include <iostream> using namespace std; #include "money.h" /**************************************************************** * Function: main * Purpose: Test the money class ****************************************************************/ int main() {    int dollars;    int cents;    cout << "Dollar amount: ";    cin >> dollars;    cout << "Cents amount: ";    cin >> cents;    Money m1;    Money m2(dollars);    Money m3(dollars, cents);    cout << "Default constructor: ";    m1.display();    cout << endl;    cout << "Non-default constructor 1: ";    m2.display();    cout << endl;   ...

  • CIT-111 Homework #5, Part A                                    Chapter 5, part 1

    CIT-111 Homework #5, Part A                                    Chapter 5, part 1 and alternate part 2 (page 341) A breakdown of the problem is as follows: Class name:                        Money Instance variables:           private, integer:                dollars, cents Constructor methods:    Money () – sets dollars and cents both to zero                                                 Money (int bucks) – sets dollars to bucks, cents to zero                                                 Money (int buck, int pennies) – sets dollars to bucks, cents to pennies Accessor methods:          getDollar () – returns value of dollars for...

  • implement a class called PiggyBank that will be used to represent a collection of coins. Functionality...

    implement a class called PiggyBank that will be used to represent a collection of coins. Functionality will be added to the class so that coins can be added to the bank and output operations can be performed. A driver program is provided to test the methods. class PiggyBank The PiggyBank class definition and symbolic constants should be placed at the top of the driver program source code file while the method implementation should be done after the closing curly brace...

  • I need help implementing class string functions, any help would be appreciated, also any comments throughout...

    I need help implementing class string functions, any help would be appreciated, also any comments throughout would also be extremely helpful. Time.cpp file - #include "Time.h" #include <new> #include <string> #include <iostream> // The class name is Time. This defines a class for keeping time in hours, minutes, and AM/PM indicator. // You should create 3 private member variables for this class. An integer variable for the hours, // an integer variable for the minutes, and a char variable for...

  • Create a simple Java class for a Month object with the following requirements:  This program...

    Create a simple Java class for a Month object with the following requirements:  This program will have a header block comment with your name, the course and section, as well as a brief description of what the class does.  All methods will have comments concerning their purpose, their inputs, and their outputs  One integer property: monthNumber (protected to only allow values 1-12). This is a numeric representation of the month (e.g. 1 represents January, 2 represents February,...

  • This assignment attempts to model the social phenomenon twitter. It involves two main classes: Tweet and...

    This assignment attempts to model the social phenomenon twitter. It involves two main classes: Tweet and TweetManager. You will load a set of tweets from a local file into a List collection. You will perform some simple queries on this collection. The Tweet and the TweetManager classes must be in separate files and must not be in the Program.cs file. The Tweet Class The Tweet class consist of nine members that include two static ones (the members decorated with the...

  • 12.24 HW2: Practice with Classes Objectives: Become familiar with developing a C++ class, to include developing:...

    12.24 HW2: Practice with Classes Objectives: Become familiar with developing a C++ class, to include developing: A constructor An multiplication operator A friend function (input operator) Introduce various C and C++ functions for parsing user input Assignment Details This assignment consists of 6 parts. Part 1: Using an IDE of your own choosing (Visual Studio is recommended), create a new project and copy the starter code ComplexNumber.h ComplexNumber.cpp and TestComplexNumber.cpp to this new project for developing and testing your solution....

  • Objectives: 1. Classes and Data Abstraction?2. User-defined classes?3. Implementation of a class in separate files Part...

    Objectives: 1. Classes and Data Abstraction?2. User-defined classes?3. Implementation of a class in separate files Part 1: In this assignment, you are asked: Stage1:?Design and implement a class named memberType with the following requirements: An object of memberType holds the following information: • Person’s first name (string)?• Person’s last name (string)?• Member identification number (int) • Number of books purchased (int)?• Amount of money spent (double)?The class memberType has member functions that perform operations on objects of memberType. For the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT