-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVARIABLES.cpp
141 lines (92 loc) · 2.03 KB
/
VARIABLES.cpp
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
//1/10
//Introduction to Variables
//2/10
//Step 1: Declare a Variable
#include <iostream>
int main()
{
// Declare a variable
int year;
}
//3/10
//Step 2: Initialize a Variable
#include <iostream>
int main() {
// Declare a variable
int year;
// Initialize a variable
year = 2019;
}
//4/10
//Combining Step 1 and Step 2
#include <iostream>
int main() {
int score = 0;
// Declare and initialize a variable here
int year = 2019;
return 0;
}
//5/10
//Arithmetic Operators
#include <iostream>
int main() {
int score = 0;
// Change score here:
score = 1234*99;
std::cout << score << "\n";
}
//6/10
//Chaining
#include <iostream>
int main() {
int score = 0;
// Output
std::cout << "Player score: " << score << "\n";
}
//7/10
//User Input
#include <iostream>
int main() {
int tip = 0;
std::cout << "Enter tip amount: ";
std::cin >> tip;
std::cout << "You paid " << tip << " dollars\n";
}
//8/10
//Challenge: Temperature (Part 1)
#include <iostream>
int main() {
double tempf = 84;
double tempc;
tempc = (tempf - 32) / 1.8;
std::cout << "The temp is " << tempc << " degrees Celsius.\n";
}
//9/10
//Challenge: Temperature (Part 2)
#include <iostream>
int main() {
double tempf;
double tempc;
// Ask the user
std::cout << "Enter the temperature in Fahrenheit: ";
std::cin >> tempf;
tempc = (tempf - 32) / 1.8;
std::cout << "The temp is " << tempc << " degrees Celsius.\n";
}
//10/10
//Review
#include <iostream>
int main() {
// Add your code below
double item_mass;
double item_mars;
std::cout << "How much does your item weigh? ";
std::cin >> item_mass;
item_mars = item_mass*3.72076;
//Create a program that asks for a distance in miles as input. The program will then output how much that distance is in kilometers.
double distance_miles;
double kmdistance;
std::cout << "How far is your distance in miles? ";
std::cin >> distance_miles;
kmdistance = distance_miles * 1.60934;
}