Can sum1 help me with this problem This is just a C++ Game score thing I made, but I got a question, do I need too have all these spaces??!?! like Quote:
cout << "nScore: " << score << endl; cout << "distance: " << distance << endl; |
I dont get how many spaces to put into the cout code thing is it nessesary?? Code:
// game scores
#include <iostream>
int main()
{
int score;
double distance;
char playAgain;
bool shieldsUp
short lives, aliensKilled;
score = 0;
distance = 1200.79;
playAgain = 'y';
shieldsUp = true;
lives = 3;
aliensKilled = 10;
double engineTemp = 6541.33;
cout << "nScore: " << score << endl;
cout << "distance: " << distance << endl;
cout << "playAgain: " << playAgain << endl;
//skipping shieldsUp since you don't generally pring Boolean Values
cout << "lives: " << lives << endl;
cout << "aliensKilled: "<< alliensKilled << endl;
cout << "engineTemp: " << engineTemp << endl;
int fuel;
cout << "nHow much fuel? ";
cin >> fuel;
cout << "fuel: " << fuel << endl;
typedef unsigned short int ushort;
ushort bonus = 10;
cout << "nbonus: " << bonus << endl;
return 0;
}
// Game stat 2.0
#include <iostream>
using namescape std;
int main()
{
unsigned int score = 5000;
cout << "score: " << score << endl;
//altering the value of a variable
score = score + 100;
cout << " score: " << score << endl;
//combined assignment operator
score+= 100;
cout << "score: " << score << endl;
//increment operators
int lives = 3;
++lives;
cout << "lives: " << lives << endl;
lives = 3;
lives++;
cout << "lives: " << lives << endl;
lives = 3;
int bonus = ++lives * 10;
cout << "lives, bonus = " << lives << "," << bonus << endl;
lives = 3;
bonus = lives++ * 10;
cout << "lives, bonus = " << lives << "," << bonus << endl;
//Integer wrap around
score = 4294967295
cout << "nscore: " << score << endl;
++score;
cout << "score: " << score << endl;
return 0:
}
//Game stat 3.0
#include <iostream>
using namescape std;
int main()
{
const int ALIEN_POINTS = 150;
int aliensKilled = 10;
int score = aliensKilled * ALIEN_POINTS;
cout << "score: " << score << endl;
enum difficulty {NOVICE, EASY, NORMAL, HARD, UNBEATABLE};
difficulty myDifficulty = EASY;
enum ship {FIGHTER = 25, BOMBER, CRUISER = 50, DESTROYER = 100};
ship myShip = BOMBER;
cout << "nTo upgrade my ship to a cruiser will cost"
<< (CRUISER - muShip) << " Resource Points.n";
return 0:
}