// payment = purchasePrice / 12
// output "Customer First Name: ", firstName
// output "Customer Last Name: ", lastName
// output "Account Number: ", acctNum
// for count = 1 to 12
// output "Payment Number ", count, ": $" , payment
having a bit of trouble transfering this part of my psuedocode into C++ format any tips or advice?
You could try something like this:
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
|
// payment = purchasePrice / 12
int payment = purchasePrice / 12;
// Note: cout and endl require #include <iostream>
// output "Customer First Name: ", firstName
std::cout << "Customer First Name: " << firstName << std::endl;
// output "Customer Last Name: ", lastName
std::cout << "Customer Last Name: " << lastName << std::endl;
// output "Account Number: ", acctNum
std::cout << "Account Number: " << acctNum << std::endl;
// Beware! There's a function named count() in <algorithm>
// for count = 1 to 12
// output "Payment Number ", count, ": $" , payment
for(int count(1); count < 13; count++) {
std::cout << "Payment Number " << count << ": $" << payment << std::endl;
}
// Unless you want to use a vector (= a better array) for payment,
// i.e. payment is something like
// std::vector<int> payment;
// or
// int payment[];
// int* payment;
// In that case:
for(int count(0); count < 12; count++) {
std::cout << "Payment Number " << (count + 1)
<< ": $" << payment[count] << std::endl;
}
|
Last edited on