added files made during the first lecture!
This commit is contained in:
parent
3fc2ba3589
commit
fadf65de90
|
@ -0,0 +1,22 @@
|
|||
// read in two numbers and add them together
|
||||
// print the result
|
||||
#include <iostream>
|
||||
//without this line you need to write std::cin std::cout
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int num1;
|
||||
int num2;
|
||||
|
||||
cout << "Enter a number: " << endl;
|
||||
cin >> num1;
|
||||
cout << "Enter another number" << endl;
|
||||
cin >> num2;
|
||||
|
||||
//test out what's in the named boxes
|
||||
cout << "num1 contains: " << num1 << endl;
|
||||
cout << "num2 contains: " << num2 << endl;
|
||||
|
||||
cout << "Adding the two numbers: " << num1 + num2 << endl;
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
string stuff;
|
||||
cout << "Enter a thing: " << endl;
|
||||
cin >> stuff;
|
||||
|
||||
cout << "You said: " << stuff << endl;
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
// Program to calculate cost of an order of pizzas
|
||||
// from how many people, cost of a pizza, slices per person, number of slices in a pizza
|
||||
// total cost = 1.25*(cost of a pizza * number of pizzas we need)
|
||||
// number of pizzas we need = number of people * slices per person / slices in a pizza
|
||||
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
int numOfPeople;
|
||||
int slicesPerPerson;
|
||||
float slicesInPizza = 12;
|
||||
float numberOfPizzas;
|
||||
//slicesInPizza = 12
|
||||
|
||||
float costPerPizza;
|
||||
float totalCost;
|
||||
float tipPercent = 1.25;
|
||||
|
||||
cout << "Enter the number of people: " << endl;
|
||||
cin >> numOfPeople;
|
||||
cout << "Enter the number of slices per person: " << endl;
|
||||
cin >> slicesPerPerson;
|
||||
cout << "Cost of a pizza: " << endl;
|
||||
cin >> costPerPizza;
|
||||
|
||||
numberOfPizzas = ceil(numOfPeople * slicesPerPerson / slicesInPizza);
|
||||
|
||||
//cout << "Testing: " << numberOfPizzas << endl;
|
||||
|
||||
totalCost = tipPercent*(numberOfPizzas * costPerPizza);
|
||||
|
||||
cout << "You bought: " << numberOfPizzas << " pizzas" << endl;
|
||||
cout << "For a cost of: " << totalCost << " dollars" << endl;
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
Loading…
Reference in New Issue