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

using c++ A. Create a text file of 15+ products including product ID’s, unit pri

ID: 3588272 • Letter: U

Question

using c++

A. Create a text file of 15+ products including product ID’s, unitprices, quantities sold, and sales of each product in your computer. Then input the file into an array of structure ADT to your program.

B. Sort the above data and adding the sales of each product. You may use either bubble sort or selection sort in ascending or descending order on sales. The arguments of call function must include arrays of structure.

C. In the program algorithm, you must use “->” structure pointer operator.

D. Print out product ID’s, unit prices, quantities sold, and the sales of each product into a second text file. And print out the total units sold and the total sales also into the second text file.

E. The file path in the desktop can be located by file property: “C:\Users\yourUsersName\Desktop\filename.txt”

Explanation / Answer

class A { public A() { n = 0; } // constructor public A(int a) { n = a; } // constructor public void f() { n++; } // mutates n public void g() { f(); n = 2 * n; f(); } // g mutates n directly and indirectly (f) public int h() { return n; } // accessor of n public void k() { System.out.println(n); } // does not return, only prints, the value of n private int n; // instance variable } class Person { public Person() { name = "YetToBeNamed"; birthdayYear = 1999; // my default } public Person(String givenName, int yearOfBirth) { name = givenName; birthdayYear = yearOfBirth; } public String getName() { return name; } public String changeName(String name) { String aux; aux = this.name; this.name = name; return aux; } public int getAgeInYears(int currentYear) { return currentYear - birthdayYear; } private String name; private int birthdayYear; public static void main(String[] args) { Person a = new Person(); Person b = new Person("Richard P. Feynman", 1918); String name = a.changeName("The Next Richard Feynman"); System.out.println( "Physicist " + name + " makes big " + "discovery, touted as " + a.getName() ); System.out.println( b.getName() + " was " + b.getAgeInYears(1945) + " in 1945, in May. " ); } }