# data[].attributes.body
#include <iomanip>

#include <iostream>

#include <string>

using namespace std;

int main() {

double length, width, area, perimeter; //double 是用来store小数点的

cout << "Enter length and wide of rectangle : ";

cin >> length;

cin >> width;

area = length * width;

perimeter = 2 * (length + width);

cout << fixed << setprecision(2); //set两个小数点

cout << "Area= " << area;

cout << "perimeter= " << perimeter;

return 0;

}

# data[].attributes.body
#include <iomanip>

#include <string>

#include <iostream>

using namespace std;

int main () {

string name;

string gender;

int age;

cout << "Your name: ";

getline(cin, name); //读完整个 如果没有放 不会读spacing后面的字

cout << "Enter your age: ";

cin >> age;

cin.ignore();

cout << "Enter your gender (M/f): ";

getline(cin, gender);

cout << "Name: " << name << endl;

cout << "Your Age: " << age << endl;

cout << "Gender: " << gender << endl;

return 0;

}

# data[].attributes.body
#include <iomanip>

#include <iostream>

#include <string>

using namespace std;

int main() {

double num = 3.142111;

cout << num << endl;

cout << setprecision(4) << num << endl;

cout << setprecision(3) << num << endl;

cout << setprecision(2) << num << endl;

cout << setprecision(1) << num << endl;

}

# data[].attributes.body
#include <iostream>

#include <iomanip>

#include <string>

using namespace std;

int main() {

int age;

bool hasLicense = true;

cout << "Your age: ";

cin >> age;

if (age >= 18 && hasLicense) {

cout << "You can drive.\n";

}

else {

cout << "You cannot drive.\n";

}

}

# data[].attributes.body
#include <iostream>

#include <iomanip>

#include <string>

using namespace std;

int main() {

bool isRaining = true;

if (!isRaining) { //! mean false

cout << "Go out without umbrella\n";

}

else {

cout << "Bring an umbrella before go out\n";

}

}

# data[].attributes.body
#include <iostream>

#include <iomanip>

#include <string>

using namespace std;

int main() {

bool hasmoney; //bool(boolean is data for true and false)

bool hascreditcard;

cout << "Do you have money? (Type 1 for yes 0 for No): "; //In c++ 1 mean True 0 mean False

cin >> hasmoney;

cout << "Did you bring your credit card? (Type 1 for yes 0 for no): ";

cin >> hascreditcard;

if (hasmoney || hascreditcard) {

cout << "You can buy the item\n";

}

else {

cout << "Your broke get out!!!!\n",

}

return 0;

}

# data[].attributes.body
#include <iomanip>

#include <iostream>

#include <string>

using namespace std;

int main() {

int day;

cout << "Enter a number (1-7): ";

cin >> day;

switch (day) {

case 1:

cout << "Monday";

break;

case 2:

cout << "Tuesday";

break;

case 3:

cout << "Wednesday";

break;

case 4:

cout << "Thursday";

break;

case 5:

cout << "Friday";

break;

case 6:

cout << "Saturday";

break;

case 7:

cout << "Sunday";

break;

default:

cout << "Invalid day!";

}

return 0;

}

# data[].attributes.body
#include <iomanip>

#include <iostream>

#include <string>

using namespace std;

int main() {

char grade;

cout << "Enter your grade : " << endl;

cin >> grade;

if (grade == 'A') {

cout << "\nExcellent!";

}

else if (grade == 'B') {

cout << "\nGood job!";

}

else {

cout << "\nKeep trying!";

}

}

# data[].attributes.body
#include <iomanip>

#include <iostream>

#include <string>

using namespace std;

int main() {

double c, f;

cout << "Enter temperature in Celcius : ";

cin >> c;

f = 32 + (c * 180 / 100);

cout << "Temperature in Fahrenheit is : " << f << endl;

return 0;

}

# data[].attributes.body
#include <iomanip>

#include <iostream>

#include <string>

using namespace std;

int main() {

int age;

bool hasl = true;

cout << "Enter your age : ";

cin >> age;

if (age >= 17 && hasl){

cout << "You can apply for car license";

}

else {

cout << "You are not old enough to apply car license";

}

return 0;

}