Académique Documents
Professionnel Documents
Culture Documents
TUGAS AKHIR
MATA KULIAH PBP
D
I
S
U
S
U
N
OLEH
#include <iostream>
#include <iomanip>
using namespace std;
// Function prototypes
char getChoice();
double patientCharges(int, double, double, double); // In-patient
double patientCharges(double, double); // Out-patient
int main()
{
char patientType; // I=in-patient, O=out-patient
int days; // Number of days of <strong class="highlight">hospital</strong> stay
double roomRate, // Daily room rate
medication, // Total medication charges
services, // Total for tests and other services
totalCharges; // Total of all charges
return 0;
}// End of main function
//************************************...
// Definition of function getChoice *
// Accepts and returns user's validated menu choice. *
//************************************...
char getChoice()
{
char letter; // Holds user's letter choice
/*************************************...
* patientCharge *
* This function is called by main to calculate and return *
* total patient charges for in-patients *
**************************************...
double patientCharges(int days, double rate, double med, double serv)
{
/*************************************...
* patientCharge *
* This function is called by main to calculate and return *
* total patient charges for out-patients *
**************************************...
double patientCharges(double med, double serv)
{
Petunjuk:
1. Gunakan langkah-langkah pembuatan template program seperti pada program
sederhana I (“Hello World!) yang lalu , tetapi gunakan Project_name yang
berbeda,misalnya Program5
2. Gantilah blok program fungsi main ( ingat,yang dimaksud blok adalah barisan
perintah diantara { dan } dari fungsi main),dengan yang berikut:
/* processing phase */
while ( counter <= 10 ) { /* loop 10 times */
printf( "Enter grade: " ); /* prompt for input */
scanf( "%d", &grade ); /* read grade from user */
total = total + grade; /* add grade to total */
counter = counter + 1; /* increment counter */
} /* end while */
/* termination phase */
average = total / 10; /* integer division */
Output Program:
Enter grade: 98
Enter grade: 76
Enter grade: 71
Enter grade: 87
Enter grade: 83
Enter grade: 90
Enter grade: 57
Enter grade: 79
Enter grade: 82
Enter grade: 94
Class average is 81
Petunjuk:
1. Gunakan langkah-langkah pembuatan template program sama seperti di atas, tetapi
gunakan Project_name yang berbeda,misalnya Program6
/* initialization phase */
total = 0; /* initialize total */
counter = 0; /* initialize loop counter */
/* processing phase */
/* get first grade from user */
printf( "Enter grade, -1 to end: " ); /* prompt for input */
scanf( "%d", &grade ); /* read grade from user */
/* termination phase */
/* if user entered at least one grade */
if ( counter != 0 ) {
Petunjuk:
1. Gunakan langkah-langkah pembuatan template program sama seperti program
sebelumnya, tetapi gunakan Project_name yang berbeda,misalnya Program7
} /* end while */
Output Program:
Enter the letter grades.
Enter the EOF character to end input.
a
b
c
C
A
d
f
C
E
Incorrect letter grade entered. Enter a new grade.
D
A
b
^Z
Totals for each letter grade are:
A: 3
B: 2
C: 3
D: 2
F: 1
#include <iostream.h>
#include <vector.h>
int main(){
int n,i,j,tmp1,tmp2;
vector <unsigned long long> arr;
bool odd;
cin>>n;
arr.push_back(0);
arr.push_back(1);
if (n>=1) cout<<arr[1]<<’\n’;
for (i=2;i<=n;i++){
odd=i%2;
tmp1=0;
for (j=1;j<=i/2;j++){
tmp2=arr[j];
arr[j]=tmp1+arr[j];
tmp1=tmp2;
}