Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help me code this lab in java Our third Lab has us in the role of a DVD S

ID: 3671192 • Letter: P

Question

Please help me code this lab in java

Our third Lab has us in the role of a DVD Store Owner…let’s just pretend this is before Netflix J. We’re in this business to make some money so we buy DVDs from our supplier for $9/each but sell each DVD to our customers for $10/each.

This program is to simulate our inventory system where we can facilitate buying, selling and querying for the current number of DVDs, as well as cash on hand, we have.

When the program starts it:

Sets the number of DVDs we currently have to 10 and sets our cash on hand to $100.

Displays a menu saying:

Welcome to DVDs R Us. Please choose from the options below:

1 – Buy DVDs

2 – Sell DVDs

3 – Check how many DVDs we have in stock

4 – Check how much cash we have

9 – Exit the program

Enter Option:

Requirements:

Within a loop, display the menu.   If the user enters an option that is not 1, 2, 3, 4 or 9, display the message “This option is not acceptable” and loop back around to redisplay the menu.   Continue in this manner until a correct option is input.

If option 1 is selected, prompt the user for the number of DVDs to buy, and once we have this number, check to see if we can afford the DVDs (based on the formula: number of DVDs to be bought * 9 <= total cash we have)

If we can, then we add the newly purchased DVDs to our current DVD count and reduce our money to whatever is left. We also output the number of DVDs we have (with the prefix text “Number of DVDs:”) and the cash we have (with the prefix text “Cash available:”) after the transaction, and re-display the main menu.

If we cannot, then we display a message saying – “You do not have enough money for this transaction”.

If option 2 is selected, prompt the user for the number of DVDs to sell, and once we have this number, check to see if we have enough to sell

If we can, then we reduce the DVD count by the amount sold and increase the money we have (by number of DVDs sold * 10). We also output the number of DVDs we have left (with the prefix text “Number of DVDs:”) and the cash we have (with the prefix text “Cash available:”) after the transaction, and re-display the main menu.

If we cannot, then we display a message saying – “You do not have enough DVDs for this transaction”.

If option 3 is selected, we output the number of DVDs we have left (with the prefix text “Number of DVDs:”) and re-display the main menu.

If option 4 is selected, we output the cash we have (with the prefix text “Cash available:”)and re-display the main menu.

If option 9 is selected then the Program ends.

Continue this looping until option 9 is selected.

Explanation / Answer

Answer -

#include <iostream>
using namespace std;

int main()
{
int ch,count_dvd=10,avail_cash=100;
do
{
cout<<" Welcome to DVDs R Us. Please choose from the options below:";
cout<<" 1 – Buy DVDs";
cout<<" 2 – Sell DVDs";
cout<<" 3 – Check how many DVDs we have in stock";
cout<<" 4 – Check how much cash we have";
cout<<" 9 – Exit the program";
cout<<" Enter Option:";
cin>>ch;
if(ch==1)
{
int dvd_to_buy;
cout<<" Enter number of DVDs to buy : ";
cin>>dvd_to_buy;
if((dvd_to_buy*9)<=avail_cash)
{
count_dvd=count_dvd+dvd_to_buy;
avail_cash=avail_cash-(dvd_to_buy*9);
cout<<" Number of DVDs : "<<count_dvd;
cout<<" Cash available : "<<avail_cash;
}
else
{
cout<<" You do not have enough money for this transaction";
}
continue;
}
else if(ch==2)
{
int dvd_to_sell;
cout<<" Enter number of DVDs to sell : ";
cin>>dvd_to_sell;
if(dvd_to_sell<=count_dvd)
{
count_dvd=count_dvd-dvd_to_sell;
avail_cash=avail_cash+(dvd_to_sell*10);
cout<<" Number of DVDs : "<<count_dvd;
cout<<" Cash available : "<<avail_cash;
}
else
{
cout<<" You do not have enough DVDs for this transaction";
}
continue;
}
else if(ch==3)
{
cout<<" Number of DVDs : "<<count_dvd;
continue;
}
else if(ch==4)
{
cout<<" Cash available : "<<avail_cash;
continue;
}
else if(ch==9)
{
break;
}
else
{
cout<<" This option is not acceptable";
continue;
}
}while(ch!=9);
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote