1

(I apologize if there's something wrong with my post as this is my first one...)

So my teacher gave this as a sample output:
1:

And this is my code:

#include <iostream>

using namespace std;

int main() {
    //variables
    string name;
    int fries = 0, burger = 0, donut = 0, ic = 0, sd = 0;
    const float friesp = 80, burgerp = 150, donutp = 30, icp = 25.50, sdp = 20;  
    int pricef = 0, priceb = 0, priced = 0, pricei = 0, prices = 0;
    float total = 0, vat = 0, bill = 0;
    
    //name of customer
    cout<<"Hi! Please type your name.";
    cin>>name;
    
    //amounts
    cout<<"Please enter the amount of fries ordered:";
    cin>>fries;
    pricef = fries*friesp;
    
    cout<<"Please enter the number of burger(s) ordered:";
    cin>>burger;
    priceb = burger*burgerp;
    
    cout<<"Please enter the number of donut(s) ordered:";
    cin>>donut;
    priced = donut*donutp;
    
    cout<<"Please enter the number of ice cream ordered:";
    cin>>ic;
    pricei = ic*icp;
    
    cout<<"Please enter the number of soft drink(s) ordered:";
    cin>>sd;
    prices = sd*sdp;
    
    //bill formula
    total = pricef+priceb+priced+pricei+prices;
    vat = total*0.20;
    bill = total + vat;
    
    //prices
    cout<<"Hi "<<name<<"! Here is the summary of your order:""\n";
    cout<<fries<<""<<" fries "<<friesp<<" "<<pricef<<"\n";
    cout<<burger<<""<<" burger(s) "<<burgerp<<" "<<priceb<<"\n";
    cout<<donut<<""<<" donut(s) "<<donutp<<" "<<priced<<"\n";
    cout<<ic<<""<<" ice cream "<<icp<<" "<<pricei<<"\n";
    cout<<sd<<""<<" soft drink(s) "<<sdp<<" "<<prices<<"\n";
    
    //billing
    cout<<"Subtotal:"<<total<<"\n";
    cout<<"20% VAT:"<<vat<<"\n";
    cout<<"Total bill:"<<bill<<"\n";
    
    return 0; 
}

I think I got the gist of it however, I do not know to to add the space in between my outputs. These spaces are what I want to achieve but don't know how...

Marek R
  • 32,568
  • 6
  • 55
  • 140
Samesassy
  • 11
  • 1
  • 1
    https://en.cppreference.com/w/cpp/io/manip/setw – Retired Ninja Nov 15 '21 at 10:43
  • 1
    For the future 1. [Do not post images](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question) of any kind of text (text paste it same way as code). 2. Take more care to provide meaningful title. It should be snappy and describe actual problem not "story of your life" (fixed for you). – Marek R Nov 15 '21 at 10:47
  • Please click [edit] to see how your question was improved to avoid future problems. – Marek R Nov 15 '21 at 10:54
  • Yes, I apologize for my inexperience and I will follow what you have said in the future. – Samesassy Nov 15 '21 at 11:13
  • No problem, it is not so bad for a first time. I'm just pointing the right direction. – Marek R Nov 15 '21 at 11:32

0 Answers0