Textbook Physics

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

/Users/alexputter/Documents/assignment5.

c
Saved: 4/9/15, 10:10:21 PM
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

Page 1 of 2
Printed For: Alex Putter

Alex Putter
Short Assignment 5
/* Input for question 1
*
* Displays monthly prices for different internet service providers
*/
#include <stdio.h>

/* printf and scanf definitions */

int main(void)
{
/* for each plan: ase price, price per MB
* and total data in MB used in month */
float baseA, permbA, baseB, permbB, MB;
/* Get the prices for plan A. */
printf("Please enter the base price and price per MB per month for plan A > ");
scanf("%f %f", &baseA, &permbA);
/* Get the prices for plan B. */
printf("Please enter the base price and price per MB per month for plan B > ");
scanf("%f %f", &baseB, &permbB);
/* Get the data usage. */
printf("Please enter your expected monthly data usage in MB > ");
scanf("%f", &MB);
/*Displays the comparison of plan A and plan B. */
printf("Plan Base Price
Price per MB Your Monthly Cost.
\n"
"------------------------------------------------------------- \n"
" A $ %5.2f
$ %5.2f
$ %7.2f
\n"
" B $ %5.2f
$ %5.2f
$ %7.2f
\n"
"------------------------------------------------------------- \n"
, baseA, permbA, baseA + permbA*MB, baseB, permbB, baseB + permbB*MB);
return(0);
}
/* Output
*engs20-3:~/engs20/workspace$ internetplan
*Please enter the base price and price per MB per month for plan
*Please enter the base price and price per MB per month for plan
*Please enter your expected monthly data usage in MB > 105
*Plan Base Price
Price per MB Your Monthly Cost.
*------------------------------------------------------------* A
$ 35.00
$ 4.50
$ 507.50
* B
$ 15.00
$ 11.50
$ 1222.50
*------------------------------------------------------------*
*engs20-3:~/engs20/workspace$ internetplan
*Please enter the base price and price per MB per month for plan
*Please enter the base price and price per MB per month for plan
*Please enter your expected monthly data usage in MB > 108
*Plan Base Price
Price per MB Your Monthly Cost.
*------------------------------------------------------------A
$ 88.00
$ 8.00
$ 952.00
B
$ 49.00
$ 2.34
$ 301.72
*-------------------------------------------------------------

A > 35 4.5
B > 15 11.5

A > 88 8
B > 49 2.34

/Users/alexputter/Documents/assignment5.c
Saved: 4/9/15, 10:10:21 PM
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

/* Input for question 2:


*
* Displays numbers in different ways
*/
#include <stdio.h>

/* printf and scanf definitions */

int main(void)
{
/* define variables */
float a = -4820.21, b = 54.8, c = .5678;
/* print variables in different forms. */
printf("|%10.3f|%-10.2f|%+8.2f|%010.4f| \n"
"|%10.3f|%-10.2f|%+8.2f|%010.4f| \n"
"|%10.3f|%-10.2f|%+8.2f|%010.4f| \n"
, a, a, a, a, b, b, b, b, c, c, c, c);
return(0);
}
/* output
* engs20-3:~/engs20/workspace$ numbers
* | -4820.210|-4820.21 |-4820.21|-4820.2100|
* |
54.800|54.80
| +54.80|00054.8000|
* |
0.568|0.57
|
+0.57|00000.5678|
*/

Page 2 of 2
Printed For: Alex Putter

You might also like