How to insert a blank line

Sep 11, 2014 at 9:18pm
Sounds really dumb and simple, but I can't figure out how to create a space between certain lines. Here's the code,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <iostream>

#include <iomanip>

using namespace std;



int main()

{

    // Variables

    double meal_cost, tax, tip, total_cost;



    // Set output for number formatting

    cout << setprecision(2) << fixed << showpoint;



    // Welcome Message

    cout << "WELCOME TO THE BROWARD CAFE!!!\n"; 



    // Ask the user to input the cost of the meal.

    cout << "Please enter the total cost of the meal:";

    cin >> meal_cost;



    // Calculate the tax amount, the tip amount and the total cost of the meal.

    meal_cost = meal_cost;

    tax =  meal_cost * 0.07;

    tip = meal_cost * 0.20;

    total_cost = meal_cost + tax + tip;

       

    // Display the calculated data.

    cout << "Meal Cost: $" << meal_cost << endl;

    cout << "Tax: $" << tax << endl;

    cout << "Tip: $" << tip << endl;

    cout << "Total Cost: $" << total_cost << endl;

    return 0;

}

Everything runs fine and it calculates what I want, I just need it to look like this with the space between "Please enter...meal" and "Meal Cost"

WELCOME TO BROWARD CAFÉ!!
Please enter the total cost of the meal: $_40_

Meal Cost: $40.00
Tax: $2.80
Tip: $8.00
Total Cost: $50.80

instead of what it currently looks like...

WELCOME TO BROWARD CAFÉ!!
Please enter the total cost of the meal: $_40_
Meal Cost: $40.00
Tax: $2.80
Tip: $8.00
Total Cost: $50.80
Sep 11, 2014 at 9:19pm
Print another '\n' or endl before you print the calculated data, but after you receive input.
Sep 11, 2014 at 9:30pm
I'm not sure exactly where to insert it, can I do it where the calculations occur?
Sep 11, 2014 at 9:41pm
insert it any where you want. You can experiment with it until you have what you want.
Sep 13, 2014 at 12:50am
cout << endl;

or "\n" inside a text string like:

cout << "This is a \n new line " << endl; <---- edl also adds a new line

or : add another endl after endl like this :

1
2
3
4
5
6
7
cout << "Meal Cost: $" << meal_cost << endl << endl;

    cout << "Tax: $" << tax << endl << endl;

    cout << "Tip: $" << tip << endl << endl;

    cout << "Total Cost: $" << total_cost << endl << endl;



Sorry didn't read your whole post but you get the idea and now you should be able to format it the way you want...
Last edited on Sep 13, 2014 at 5:23am
Topic archived. No new replies allowed.