Im making a drink machine program and I want all the prices to line up together.
Is there some way to tell the compiler to write the price X number of spaces from the start of the line instead of adding spaces after the drink name is posted?
int main()
{
const int arrsize = 5;
Drinks arr[arrsize] = {
{"Cola",.75,20},
{"Root Beer",.75,20},
{"Lemon-Lime",.75,20},
{"Grape Soda",.80,20},
{"Cream Soda",.80,20},
};
for (;;){
cout << "Please select a drink: "<<endl;
for (int i = 0; i < arrsize; i++){
cout << (i+1)<<". "<< arr[i].DrinkName;
cout << setw(10) << setfill(' ')<< right <<fixed << arr[i].DrinkCost<<endl;
}
cout <<"6. Quit";
break;
}
return 0;
}
What I want is for it to look like this:
Please select a drink:
1. Cola 0.75
2. Root Beer 0.75
3. Lemon-Lime 0.75
4. Grape Soda 0.80
5. Cream Soda 0.80
6. Quit
But it comes out looking like this:
Please select a drink:
1. Cola 0.75
2. Root Beer 0.75
3. Lemon-Lime 0.75
4. Grape Soda 0.80
5. Cream Soda 0.80
6. Quit