Using Visual Studio, C# Programming
Lecture: Objects, Inheritance and abstract classes, member init list, shape, circle and cylinder.
Complete Exercises 4 and 5 (100pts)
4. Person and customer classes
Design a class named Person with properties for holding a person's name, address, and telephone number. Next, design a class named Customer, which is derived form the Person class. The Customer class should have a property for a customer number and a Boolean property indicating whether the customer wishes to be on a mailing list, Demonstrate an object of the Customer class in a simple application.
5. PreferredCustomer Class
A retail store has a preferred customer plan where customers can earn discounts on all their purchases. The amount of a customers discount is determined by the amount of the customers cummulative purchases in the store as follows:
- When a preferred customer spends $500, he or she gets a 5 percent discount on all future purchases.
- When a preferred customer spends $1,000, he or she gets a 6 percent discount on all future purchases.
- When a preferred customer spends $1,500, he or she gets a 7 percent discount on all future purchases.
- When a preferred customer spends $2,000, he or she gets a 10 percent discount on all future purchases.
Design a class named PreferredCustomer, which is derived from the Customer class you created in Exercise 4. The PreferredCustomer class should have properties for the amount of the customer's purchases and the customer's discount level. Demonstrate the class in a simple application.
Complete below for 100pts extra credit
Person[] people=new Person[2];
people[0]=new Customer(arguments here);
people[1]=new Preferredcustomer(arguments here);
people[0].calcdiscount();
people[1].calcdiscount();
| use overridden methods to effect polymorphism. | overload operators
to enable them to manipulate objects. |
| determine an
object’s type at execution time. |
create sealed
methods and classes. |
| create abstract
classes and methods. |
In: Computer Science
I am working on a currency exchanging vending machine. I got it to work until the currency exchange section but the money won't be put into userAmount for the final section and it just repeat the currency exchange section.
Here is my code:
#include <cctype>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <iomanip>
using namespace std;
double convert(double currency, double conversionRate)
{
return currency * conversionRate;
}
int menu() {
char choice;
int price;
cout << "Welcome to the snack vending machine"
<< endl;
cout << endl;
cout << "Available snacks to select from:"
<< endl;
cout << "\t L - Lays Chips \t $2" <<
endl;
cout << "\t S - Snickers \t $5" <<
endl;
cout << "\t P - PopTart \t \t $3" <<
endl;
cout << "\t C - Cookies \t \t $5" <<
endl;
cout << "\t B - Browine \t \t $2" <<
endl;
cout << "\t N - Nuts \t \t $5" <<
endl;
while (1) {
cout << "Please enter the
letter labeling your snack selection: ";
cin >> choice;
choice = toupper(choice);
if (choice == 'L') {
price = 2;
break;
}
else if (choice == 'S') {
price = 5;
break;
}
else if (choice == 'P') {
price = 3;
break;
}
else if (choice == 'C') {
price = 5;
break;
}
else if (choice == 'B') {
price = 2;
break;
}
else if (choice == 'N') {
price = 5;
break;
}
else
cout <<
"Invalid selection!" << endl << endl;
}
return price;
}
int acceptMoney(int price) {
int userAmount = 0;
int choice;
double currency1, currency2;
do
{
cout << " CURRENCY
CONVERSION" << endl << endl;
cout << "1. Euros to Dollars"
<< endl;
cout << "2. Peso to Dollars"
<< endl;
cout << "3. Pounds to
Dollars" << endl;
cout << "4. Exit" <<
endl << endl;
cout << "Select your choice:
";
cin >> choice;
while (choice < 0 || choice >
4)
{
cout <<
"Enter a valid option: ";
cin >>
choice;
}
cout << endl;
switch (choice)
{
case 1: cout << "Enter amount
in Euros: ";
cin >>
currency1;
currency2 =
convert(currency1, 1.11);
cout <<
"Amount in Dollars: " << currency2;
userAmount +=
currency2;
break;
case 2: cout << "Enter
amount in Peso: ";
cin >>
currency1;
currency2 =
convert(currency1, 0.052);
cout <<
"Amount in Dollars: " << currency2;
userAmount +=
currency2;
break;
case 3: cout << "Enter
amount in Pounds: ";
cin >>
currency1;
currency2 =
convert(currency1, 1.31);
cout <<
"Amount in Dollars: " << currency2;
userAmount +=
currency2;
break;
case 4: break;
}
cout << endl <<
endl;
} while (choice != 4);
return price;
}
int computeChange(int totalPaid, int totalPrice) {
return totalPaid - totalPrice;
}
int main()
{
int totalPrice, totalPaid, change;
char choice;
while (1) {
totalPrice = menu();
totalPaid =
acceptMoney(totalPrice);
change = computeChange(totalPaid,
totalPrice);
cout << endl;
cout << "Your total inserted:
" << totalPaid << " Dollars" << endl;
cout << "Dispensing change: "
<< change << " Dollars" << endl;
cout << endl;
cout << "Would you want to
make another purchase? (Y/N): ";
cin >> choice;
cout << endl;
choice = toupper(choice);
if (choice == 'N') {
cout <<
"Thank you!!!" << endl;
break;
}
cout << endl;
}
return 0;
}
In: Computer Science
when is it more appropriate to use online storage as compared to offline storage
In: Computer Science
Prepare a list of five Web sites that job seekers should visit
for advice about cover letters and résumés, including online
postings. Include a one-paragraph summary of the material found on
each site.
In: Computer Science
In: Computer Science
def compare_elevations_within_row(elevation_map:
List[List[int]], map_row: int, level: int) -> List[int]:
"""Return a new list containing the three counts: the number
of
elevations from row number map_row of elevation map
elevation_map
that are less than, equal to, and greater than elevation level.
Precondition: elevation_map is a valid elevation map.
0 <= map_row < len(elevation_map).
>>> compare_elevations_within_row(THREE_BY_THREE, 1,
5)
[1, 1, 1]
>>> compare_elevations_within_row(FOUR_BY_FOUR, 1,
2)
[0, 1, 3]
"""
for i in elevation_map[map_row]:
differences=[0,0,0]
if i<level:
differences[0] += 1
elif i==level:
differences[1] += 1
else:
differences[2] += 1
return differences
This was written in python, I am wondering why does the header of the function shows syntax error starting from List. (List[List[int]], map_row: int, level: int) -> List[int]:)these are all underedline
In: Computer Science
In: Computer Science
Using the following schema, write a SQL query to satisfy the question: What are the names of the suppliers of 'Pith_helmet' sold in a department managed by 'Andrew'?
Schema:
Sale (saleno, saleqty, itemno, dname)
Supplier (splno, splname)
Item (itemno, itemname, itemtype, itemcolor)
Department (deptname, deptfloor, deptphone, empno)
Delivery (delno, delqty, itemnum, dptname, splno)
Employee (empno, empfname, empsalary, departname, bossno)
In: Computer Science
Question 2: Create a class Fract fraction with two private integer data members: num (Numerator) and den (denominator). write code for:
Part A) class declaration header file
Part b) constructor that validates input (prevent 0 on the denominator in a fraction simplified fraction that is not reduced, avoids negative denominators) with default arguments 0 and 1.
Part c)Two fractions with prototype Fract add (fract) and Fract multiply (fract) completing the usual addition and multiplication
Part d) Just all fractions by writing a short test driver that creates two fractions with the values 3/6 and ⅔ and prints there sum and product
C++ language
In: Computer Science
IN C++ PLEASE
Given a Student class, create a class with following characteristics
Input
Jack
1
Jones
2
Marry
3
where,
Output
1 - Jack
2 - Jones
3 - Marry
Assume that,
Given Code:
#include<iostream>
#include<cstring>
#include <algorithm>
using namespace std;
class Student{
public:
string name;
int rollNo;
};
//write your code here
int main()
{
string name;
char temp[20];
int rollNo, N, i;
Student * students;
ClassRoom classRoom;
i=0;
while(getline(cin, name) && cin.getline(temp,20)){
rollNo = atoi(temp);
classRoom.addStudent(name, rollNo);
i++;
}
N = i;
students = classRoom.getAllStudents();
for(int i=0 ; i < N; i++){
cout << (students+i)->rollNo << " - " <<
(students+i)->name;
if(i<N-1)
cout<<endl;
}
return 0;
}
In: Computer Science
Write a function in Matlab that will compute the approximation for ln(x) given the inputs to the function are x and n. This function requires a running sum using a for-loop. ln (?) = lim?→∞∑ (−1)^(?−1)*(? − 1)^?/k
In: Computer Science
The purpose of this exercise is to provide the Marketing
department with a method to sort a predefined data list by zip
code, last name, first name so they can take advantage of bulk
mailing rates.
Assignment: 1. Create a table with the following fields called
"Homework1Data" with (4 fields), then run the inserts below into
the table (Figure 1-1). 2. Write a single SQL Query that has the
following fields (6 fields so they can easily be moved around using
a Mail Merge) using these names (alias); Firstname, Lastname,
Address, City, State, Zip be sure to sort by zip code, last name,
first name 3. Turn in a copy of your SQL Query (single statement -
not a procedure)
Hint: The magic exist in the string manipulation functions (LENGTH,
INSTR, SUBSTR, etc.)
Figure 1-1:
CREATE TABLE homework1data ( name VARCHAR2(30), address
VARCHAR2(30), location VARCHAR2(30), zip VARCHAR2(10));
----------------------------------------- INSERT INTO Homework1Data
(Name, Address, Location, Zip) VALUES ('Ferguson, Shawn M.', '1940
Fountainview Court', 'Reynoldsburg, Ohio', '43068'); INSERT INTO
Homework1Data (Name, Address, Location, Zip) VALUES ('Phillips,
George', '19 Pleasant St.', 'Columbus, OH', '43231'); INSERT INTO
Homework1Data (Name, Address, Location, Zip) VALUES ('Thompson,
Mary', '200 E. Main St.', 'Columbus, Oh', '43215'); INSERT INTO
Homework1Data (Name, Address, Location, Zip) VALUES ('Swatson,
Robert', '584 Yellowstone Dr.', 'Westerville, OH', '43081'); INSERT
INTO Homework1Data (Name, Address, Location, Zip) VALUES ('Banks,
Heather T.', '19 Pleasant St.', 'Columbus, Ohio', '43231');
In: Computer Science
In: Computer Science
In: Computer Science
What is the circuit diagram of password based door lock system project by using interface 8088 microprocessor with peripherals Ics ( PPI , PIT and PIC ) and what is code by using assembly language ?
notes:
1- this question related to microprocessor Interface subject
.
2- I need answer after 4 hour very necessary , please
In: Computer Science