Last active
December 2, 2016 03:34
-
-
Save tylersloeper/07b054e5a0d3ddd19995d4e94c78ff91 to your computer and use it in GitHub Desktop.
CS50 Pset01 (3 parts)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <cs50.h> | |
int main(void) | |
{ | |
float money; | |
float tempmoney; | |
//float startmoney; | |
int quarter; | |
quarter = 0; | |
int dime; | |
dime = 0; | |
int nickel; | |
nickel = 0; | |
int penny; | |
penny = 0; | |
printf("Please provide me with an amount of money that you would like in change, and I will calculate the smallest number of coins needed to reach that amount. Please input your dollar and cents amount here (for example nine dollars and fifty cents as 9.50)\n"); | |
money = GetFloat(); | |
START: //(startmoney = money); | |
if (money < 0) | |
{ | |
printf("You chose an invalid amount. Please input a correct number"); | |
money = GetFloat(); | |
goto START; | |
} | |
else | |
{ | |
{ | |
//decrease and count variable until money = 0, then present the variables and their values. | |
do | |
{ | |
(tempmoney = money); | |
if (money >= 0.25) | |
{ | |
money = tempmoney - 0.25; | |
(quarter++); | |
} | |
else if (money >= 0.1) | |
{ | |
money = tempmoney - 0.1; | |
(dime++); | |
} | |
else if (money >= 0.05) | |
{ | |
money = tempmoney - 0.05; | |
(nickel++); | |
} | |
else if (money > 0.009 || money == 0.01) | |
{ | |
money = tempmoney - 0.01; | |
(penny++); | |
} | |
else | |
{ | |
int k = quarter + dime + nickel + penny; | |
//printf("input of %g yields output of %i \n", startmoney, k); | |
printf("%i\n", k); | |
return 0; | |
} | |
} | |
while (money > -0.01); | |
} | |
} | |
} | |
//made by tyler loeper CS50 6/15/2016 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <cs50.h> | |
int main(void) | |
{ | |
int n; | |
int a; | |
int b; | |
int c; | |
START: printf("I would like to generate a pyramid for you on your screen. Can you please provide me with a height for this pyramid (a number between 1 and 23) so that I can make it for you?\n"); | |
n = GetInt(); | |
int k = n; | |
if (n == 0) | |
{ | |
return 0; | |
} | |
if (n >= 1 && n <= 23) | |
{ | |
for ( a = 0; a < n; n--) | |
{ | |
for ( b = 1; b < n ; b++ ) | |
{ | |
printf(" "); | |
} | |
for ( c = -1; c < k - b ; c++ ) | |
{ | |
printf("#"); | |
} | |
printf("#\n"); | |
} | |
} | |
else | |
{ | |
printf("That is not a usable number try again.\n"); | |
{ | |
goto START; | |
} | |
} | |
} | |
//made by tyler loeper CS50 6/14/2016 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <cs50.h> | |
int main(void) | |
{ | |
int n; | |
int k; | |
{ | |
printf("Please let me know how many minutes you spend in the shower when you take a normal shower?\n"); | |
} | |
n = GetInt(); | |
{ | |
k = n * 12; | |
printf("Did you know that a %i minute shower uses approximately", n ); | |
printf(" %i (sixteen ounces) bottles of water over over the course of that entire shower? That's a lot of water!\n", k ); | |
} | |
printf("Program ends...\n"); | |
} | |
//made by tyler loeper CS50 6/14/2016 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mario.c