Sutekh's C++ +More Thread

Adebisi

Clump of Cells
<Silver Donator>
27,903
30,706
#include <iostream>

using namespace std;

int main()
{
string name = "Simon Adebisi";
string phone = "555-205-1010";
string address = "66 Ozwald Rd";
string color = "blue";
cout << "Hi, My name is " << name << " and my phone number is " << phone << ". I live at " << address << " and my favorite color is " << color << endl;

return 0;
}
 

Sutekh

Blackwing Lair Raider
7,489
107
Nope, well depending on what IDE you use.

Some don't include string.h in iostream.h.


you're so smart.

edit: whoops, IDE not IED.
 

Adebisi

Clump of Cells
<Silver Donator>
27,903
30,706
I'm using some online c++ compiler
frown.png


I installed Visual C++ Express but I don't know how to get just a basic new program started, or how to run the little code I try :S

Soon

Amod...please change the name of this thread to Answer the question above you, or write a C++ program, no matter what it is
 

Sutekh

Blackwing Lair Raider
7,489
107
If visual C++ is anything like Visual studio it's a huge pain in the ass, basically have to start a new win32 application project, and from there create a source file (cpp) in the project.

Mix this shit up yo.

Will you write a program that computes the tax and tip on a restaurant bill for a patron with a 44.50 meal charge. The tax should be 6.75 percent of the meal cost.
The tip should be 15 percent of the total after adding the tax. Display the meal cost, tax amount, tip amount and total bill on the screen?
 

Sutekh

Blackwing Lair Raider
7,489
107
Please remove Dacianprick, King of the Mad's posts as they are not C++ related!
 

Adebisi

Clump of Cells
<Silver Donator>
27,903
30,706
If visual C++ is anything like Visual studio it's a huge pain in the ass, basically have to start a new win32 application project, and from there create a source file (cpp) in the project.

Mix this shit up yo.

Will you write a program that computes the tax and tip on a restaurant bill for a patron with a 44.50 meal charge. The tax should be 6.75 percent of the meal cost.
The tip should be 15 percent of the total after adding the tax. Display the meal cost, tax amount, tip amount and total bill on the screen?
I have no idea if I'm doing this the most efficient way :p.

How do I keep it to two decimal points?

#include <iostream>

using namespace std;

int main()
{
double meal = 44.50;
double tax = 0.0657;
double tip = 0.15;
double tipNtax = (meal *tax)+meal;
cout << "Meal: $" << meal << endl;
cout << "Tax: " << tax *100 << "%" << endl;
cout << "Tip: " << tip * 100 << "%" << endl;
cout << "Total: $" << (tipNtax*tip)+tipNtax << endl;


return 0;
}
 

Sir Funk

Molten Core Raider
1,251
155
need to #include <iomanip>

cout << "Total: $" << setprecision(2) << (tipNtax*tip)+tipNtax << endl;
 

Sutekh

Blackwing Lair Raider
7,489
107
I have no idea if I'm doing this the most efficient way :p.

How do I keep it to two decimal points?

#include <iostream>

using namespace std;

int main()
{
double meal = 44.50;
double tax = 0.0657;
double tip = 0.15;
double tipNtax = (meal *tax)+meal;
cout << "Meal: $" << meal << endl;
cout << "Tax: " << tax *100 << "%" << endl;
cout << "Tip: " << tip * 100 << "%" << endl;
cout << "Total: $" << (tipNtax*tip)+tipNtax << endl;


return 0;
}
Doesn't necessarily have to have two decimal points, but could just use what Sir Funk said.
But tax amount would be the tax for the meal cost, ditto for tip amount (after tax was added) and then total would be all three fields combined.
Efficiency really isn't all that important when doing shit this small, but you could do something like

double meal = 44.50, tax = 0.0657, tip = 0.15;
cout << "Meal: $\n" << meal << "Tip is: \n << tip etc.
 

Adebisi

Clump of Cells
<Silver Donator>
27,903
30,706
Next beginner challenge kind sir! Or is this a clever ploy to get me to do Sutekh's homework?
 

Izo

Tranny Chaser
20,025
24,961
10 PRINT "Thread"
20 PRINT "delivers"
30 PRINT "somewhat."
40 GOTO 10
 

Sutekh

Blackwing Lair Raider
7,489
107
Next beginner challenge kind sir! Or is this a clever ploy to get me to do Sutekh's homework?
They're just old things from a book I bought like 5 years ago. YOU DIDN'T DO THE RESTAURANT CALCULATIONS CORRECTLY SEE MY POST AFTER.
 

Adebisi

Clump of Cells
<Silver Donator>
27,903
30,706
fahhhhzooooo

I guess I could've just added the meal, tax, tip variables for the total variable :p
 

Tuco

I got Tuco'd!
<Gold Donor>
49,530
88,388
I don't get to use recursion enough at my job, only my global planners get to use it =(

I forgot what a laggy piece of shit visual studio 2010 is. I do all my shit in linux these days.