Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Wichie Statle Univenty Cs 311 Spring 20tE Homework #1 A Structured Account Assig

ID: 3876579 • Letter: W

Question

Wichie Statle Univenty Cs 311 Spring 20tE Homework #1 A Structured Account Assigned:DATE will une struets to repeesene hark accoerts and moncy respectively, and wris funcions that allow us to inicract wth our accous. Nane yuur snarce eode file progran1.opp Create twe tructares and sane the types Account ard Money. The Money dract has tuo variales - One represents bow many dollars you have. The oher represcnts how maey ceets yoe have. The Account strct hon dhree variablex - A Money stract that will represess how sech money is in the Aco One variale to rEPsT the isteresi rale as a deciial valuc The firal vaniable will contain the same of the aopoenk. (Checking. Savings. CD ew) Nepotive amcents of Honey are storod by making both variahks of the Money object negative ·Uve the following function peoerypes “Account ereateneoounto . The fenction shall pomp the eser for an accOu e, aerest eae and starting bolance in h order Let's set up your account Nhat is the intereat rate of your NAMEccount? The prompts shuil sppear as follows Finally, what is the starting balance of your NAME1 acoount? [NAME] shall be replacrd with the name of the account You may NOT a ount that the name of te aooua octaias utly a single word . You may assunse the usor will always type an inacrest rae an a decimal valee (eg., 005) - You may abo asuse the a pesitive and valid (whole number or ao moee than two decimal places) amoust of money will be entered - Account depoait (Account account, Money depositl The function shall aot aocept negative amounts of money If a negative asoant of moncy is atlemeted to be deposiled, an exsoe message will be displayod and the original account will be retarsed

Explanation / Answer

here is your program : ------------------->>>>>>>>>>>>>>

#include<iostream>

using namespace std;

struct Money{
int dollor;
int cents;
};

typedef struct Money money;

struct Account{
money balance;
float rate;
string name;
};

typedef struct Account account;

account createAccount(){
account temp;
system("cls");
cout<<" Let's set up Your Account , ";
cout<<" First, what is the name of the Account : ";
cin>>temp.name;
cout<<" What is the interest rate of your "<<temp.name<<" Account : ";
cin>>temp.rate;
cout<<" Finally,what is the starting balance of your "<<temp.name<<" Account : ";
float bal;
cin>>bal;
temp.balance.dollor = (int)bal;
temp.balance.cents =(int)((bal - temp.balance.dollor)*100);

return temp;
}

account deposit(account acc,money deposit){
if(deposit.dollor < 0 || deposit.cents < 0){
  cout<<" cannot deposit negative balance ";
}else{
   acc.balance.cents = acc.balance.cents + deposit.cents;
   acc.balance.dollor = acc.balance.dollor + deposit.dollor;
   if(acc.balance.cents > 100){
    acc.balance.cents = acc.balance.cents - 100;
    acc.balance.dollor = acc.balance.dollor + 1;
   }
   cout<<" $"<<deposit.dollor<<"."<<deposit.cents<<" is deposited to your "<<acc.name<<" account";
}
return acc;
}
account withdraw(account acc,money withdraw){
if(withdraw.dollor < 0 || withdraw.cents < 0){
cout<<" cannot deposit negative balance ";
}else if((acc.balance.dollor + 90) < withdraw.dollor){
  cout<<"Your Account "<<acc.name<<" cant have that much money to withdraw ";
}
else{
   if(acc.balance.cents < withdraw.cents){
    acc.balance.cents = acc.balance.cents + 100;
    acc.balance.cents = acc.balance.cents - withdraw.cents;
    acc.balance.dollor = acc.balance.dollor - 1;
   }
   acc.balance.dollor = acc.balance.dollor - withdraw.dollor;
   cout<<" $"<<withdraw.dollor<<"."<<withdraw.cents<<" is withdraw from your "<<acc.name<<" account";
}
return acc;
}

void update(account &acc){
acc.balance.dollor = acc.balance.dollor + (int)((acc.balance.dollor)*acc.rate);
cout<<" At "<<acc.rate<<" % Your Account "<<acc.name<<" earned $"<<((int)((acc.balance.dollor)*acc.rate))<<"";
}

void print(account acc){
if(acc.balance.dollor < 0){
  cout<<"($"<<acc.balance.dollor<<"."<<acc.balance.cents<<" )";
}else{
  cout<<" $"<<acc.balance.dollor<<"."<<acc.balance.cents;
}
}
void print(money mon){
if(mon.dollor < 0){
  cout<<"($"<<mon.dollor<<"."<<mon.cents<<" )";
}else{
  cout<<" $"<<mon.dollor<<"."<<mon.cents;
}
}

int main(){
account acc = createAccount();
cout<<" In your "<<acc.name<<" You have ";
print(acc);
money with;
with.dollor = 50;
with.cents = 12;
withdraw(acc,with);

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote