100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
COS1511 ASSIGNMENT 2 2021/2022 R55,95   Add to cart

Exam (elaborations)

COS1511 ASSIGNMENT 2 2021/2022

 17 views  1 purchase

COS1511 ASSIGNMENT 2 2021/2022 COS1511 Assignment 2 Question 1 #include <iostream> #include <iomanip> using namespace std; int main() { //Fill in the code to define an integer cariable called selection int selection, number; float cost; cout << "Please enter the c...

[Show more]

Preview 3 out of 20  pages

  • May 17, 2022
  • 20
  • 2021/2022
  • Exam (elaborations)
  • Questions & answers
All documents for this subject (26)
avatar-seller
Tutor23
COS1511
ASSIGNMENT 2
2021/2022

,COS1511 Assignment 2


Question 1
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
//Fill in the code to define an integer cariable called selection
int selection, number;
float cost;

cout << "Please enter the choice of hotdog "
<< "(a number from 1 to 4 or 0 to quit)" << endl;
cout << "Hot dog Menu " << endl << endl;
cout << "1: Plain Hotdog " << endl;
cout << "2: Chilli Hotdog " << endl;
cout << "3: Cheese Hotdog " << endl;
cout << "4: Russian Hotdog " << endl;
cout << "0: QUIT " << endl << endl << endl;

cin >> selection;

while (selection > 4 || selection <0 ) //complete the condition
{
cout << "Invalid coice - Please re-enter ";
cin >> selection;
}

cout << "You have selected option number " << selection << endl;
cout << "How many hotdogs would you like? " << endl;

//Fill in the code to read number
cin >> number;

//Fill in the code to begin a switch statement that is controlled by selection
switch (selection)
{
case 1: cost = number * 15.0;
cout << "The total cost is R" << cost << endl;
break;
case 2: cost = number * 12.50;
cout << "The total cost is R" << cost << endl;
break;

, case 3: cost = number * 17.00;
cout << "The total cost is R" << cost << endl;
break;
case 4: cost = number * 22.50;
cout << "The total cost is R" << cost << endl;
break;
case 0: cout << "Please come again" << endl;
break;
default:
cout << "Invalid selection";
cout << "Try again please" << endl;
}

return 0;
}

Output:

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through EFT, credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying this summary from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller Tutor23. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy this summary for R55,95. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

67474 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy summaries for 14 years now

Start selling
R55,95  1x  sold
  • (0)
  Buy now