2017 Winter CIS200 Lab 10 Release date: April 6, 2017 Due date: April 20, 2017 G
ID: 3819863 • Letter: 2
Question
2017 Winter CIS200 Lab 10 Release date: April 6, 2017 Due date: April 20, 2017 Given: struct clientData int accountNumber, char lastName[ 15]; char firstNamel 10 float balance; Create a random access file of 100 records named "credit.dat" using these code segments: ofstream outCredit( "credit dat", ios: out clientData blank Client 10, 0.0 for (int i 0; i 100, i++) out Credit, write (reinterpret castsconst char &blankclient;), sizeof( clientData) Kostream member function write The Kostream member function write outputs a fixed number of bytes beginning at a specific location in memory to the specific stream. When the stream is associated with a file, the data is written beginning at the location in the file specified by the "put" file pointer. The write function expects a first argument of type const char hence us the reinterpret cast const char to convert the address of the blankClient to a const char The second argument of write is an integer of type size t specifying the number of bytes to written. Thus the use of sizeof( clientData)Explanation / Answer
public class CreditCardDebt { //Instance Variables private String cardName; private double princBal; private double aPR; private double monthPayPercent; private double monthPayAmount; //Constructor public CreditCardDebt(String name, double origBal, double apr, double mnthPercent, double mnthAmount) { cardName = name; princBal = origBal; aPR = apr; monthPayPercent = mnthPercent; monthPayAmount = mnthAmount; } //Mutator/Setter public void cardName(String name){ cardName = name; } public void princBal(double origBal){ princBal = origBal; } public void aPR(double apr){ aPR = apr; } public void monthPayPercent(double mnthPercent){ monthPayPercent = mnthPercent; } public void monthPayAmount(double mnthAmount){ monthPayAmount = mnthAmount; } //Accessor/Getter public String getCardName () { return cardName; } public double getPrincBal () { return princBal; } public double getAPR () { return aPR; } public double getMonthPayPercent () { return monthPayPercent; } public double getMonthPayAmount () { return monthPayAmount; } //Other Methods public double addPurchase () { return princBal+; } public double makePay () { return -princBal; } public double calcMonthInterestAmnt () { return princBal*(aPR/12); } public doublt calcMinMonthPay () { return princBal * //toString public String toString () { return "Card: " + cardName + " has a principle balance of: " + princBal + ", an APR of " + aPR + ", a minimum monthly payment percentage of " + monthPayPercent + ", and a minimum monthly payment amount of " + monthPayAmount + "."; } }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.