CIS170 Week 6 Lab Menu Driven Application Source Code.docx - Week 6 Lab Menu Driven Application#include\"stdafx.h#include <iostream>#include <string>

CIS170 Week 6 Lab Menu Driven Application Source Code.docx...

This preview shows page 1 - 2 out of 2 pages.

Week 6 Lab Menu Driven Application #include "stdafx.h" #include <iostream> #include <string> using namespace std; class RetailItem { //declaring variables private : string description; int unitsOnHand; double price; //functions public : RetailItem() { description = "" ; unitsOnHand = 0; price = 0.0; } RetailItem( string desc , int unit , double p ) { description = desc ; unitsOnHand = unit ; price = p ; } string getDescription() { return description; } int getUnitsOnHand() { return unitsOnHand; } double getPrice() { return price; } void setDescription( string desc ) { description = desc ; } void setUnitsOnHand( int unit ) { unitsOnHand = unit ; } void setPrice( double p ) { price = p ; } }; int main() { RetailItem r[3]; string desc;
Image of page 1
int unit = 0; double price = 0.0; cout << "Welcome to the Retail store \n" << endl; cout << "Price must be greater than 0. \n" << endl; for ( int i = 0; i<3; i++) { cout << "Please enter the description for item " << i + 1 << " : " ; getline(cin, desc); //validating the no of unit >0 while (unit <= 0) { cout << "Please enter the units on hand for item "
Image of page 2

You've reached the end of your free preview.

Want to read both pages?

  • Fall '17

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes