Rainbow Bracelet

for each stone: name of the stone, color of the store, weight of the stone, and price of the store
colors: blue topaz, peridot, citrine, garnet, amethyst

Implement a program in C++ that
-uses a data structure implementing pointers and stores information about the rainbow bracelet
- reads data about the bracelet from the user
- must be able to read data as many as gems as the users wants
- displays all the information about the rainbow bracelet with the correct order of gems
-calculates and displays the total Gem weight in Carats(ct.)
-calculates and display the total Price of the bracelet (in US$)




#include <iostream>
#include <string>
using namespace std;

typedef string braceletType;

struct nodeType;

typedef nodeType *nodePtr;

struct nodeType{
braceletType name;
braceletType color;
braceletType weight;
braceletType price;
nodePtr next;
};

nodePtr front = NULL;
nodePtr rear = NULL;

void addItem()
{
braceletType newItem;
cout << "Enter name of the stone: ";
cin >> newItem
nodePtr newptr = new nodeType;
newptr ->name = newItem
cout << "Enter the color of the stone:";
cin >> newItem;
newptr ->color = newItem;
cout << "Enter the weight of the stone: ";
cin >> newItem;
newptr ->weight = newItem;
cout << "Enter the price of the stone: ";
cin >> newItem;
newptr ->next = NULL
if(front == NULL)
front = rear = newptr;
else
{
rear->next = newptr;
rear = newptr;
}
}

void printItems()
{
nodePtr braceletptr = front;
nodePtr tempptr = braceletptr;
while(braceletptr != NULL)
{
cout << braceletptr->name << "\t" << braceletptr->color << braceletptr->weight << braceletptr->price << endl;
braceletptr = braceletptr-->next;
tempptr = braceletptr;
}
}

int main()
{
int input;

do{
cout<<"********TABLE********" << endl;
cout<<"1. Add stone name,color, weight, and price" <<endl;
cout<<"2.Print all the stones" << endl;
cout<<"3. Exit the program" << endl;
cout<< "Enter your choice (1,2, or3): ";
cin>> input;

switch(input)
{
case 1:
addItem();
cout <<"Stone added" << endl;
break;
case 2:
cout << "The properties of the bracelet" << endl;
datebase
printItems();
cout << endl;
break;
default:
break;
}

}while ( (input ==1) || (input ==2));

return 0;

}



And the question is ?
Topic archived. No new replies allowed.