Question

In: Computer Science

Write two classes Class A and Class B in class A you should read from the...

Write two classes Class A and Class B in class A you should read from the keyboard a number and you should call a public method of the class B that will print on the screen whether the number that was read from the keyboard in class A is multiple of 7 and has the last digit 5.

Solutions

Expert Solution

There can be multiple approches to this problem, One such approch is using inheritance, where class A inherits class B. This will in turn give class A the ability to use class B functions.

I have implemented the above program in c++ and python.

Python implementation

C++ Implementation


Related Solutions

Classes and Objects Write a program that will create two classes; Services and Supplies. Class Services...
Classes and Objects Write a program that will create two classes; Services and Supplies. Class Services should have two private attributes numberOfHours and ratePerHour of type float. Class Supplies should also have two private attributes numberOfItems and pricePerItem of type float. For each class, provide its getter and setter functions, and a constructor that will take the two of its private attributes. Create method calculateSales() for each class that will calculate the cost accrued. For example, the cost accrued for...
Hill Corporation is organized with two classes of voting common stock: Class A and Class B....
Hill Corporation is organized with two classes of voting common stock: Class A and Class B. Shares in each class of stock have an equal right to Hill’s assets and earnings and profits. Frank owns 100 shares of Class A stock, and Fay and Joyce each own 50 shares of Class B stock. Assuming that Hill Corporation has ample earnings and profits, determine whether the following distributions are taxable under § 301 or excludable under § 305(a): Answer for d-i?...
Hill Corporation is organized with two classes of voting common stock: Class A and Class B....
Hill Corporation is organized with two classes of voting common stock: Class A and Class B. Shares in each class of stock have an equal right to Hill’s assets and earnings and profits. Frank owns 100 shares of Class A stock, and Fay and Joyce each own 50 shares of Class B stock. Assuming that Hill Corporation has ample earnings and profits, determine whether the following distributions are taxable under § 301 or excludable under § 305(a): (a)A pro rata...
Hill Corporation is organized with two classes of voting common stock: Class A and Class B....
Hill Corporation is organized with two classes of voting common stock: Class A and Class B. Shares in each class of stock have an equal right to Hill’s assets and earnings and profits. Frank owns 100 shares of Class A stock, and Fay and Joyce each own 50 shares of Class B stock. Assuming that Hill Corporation has ample earnings and profits, determine whether the following distributions are taxable under § 301 or excludable under § 305(a): Answer for d-i?...
Objectives:  Write classes in C++  Use dynamic arrays  Write and read from files...
Objectives:  Write classes in C++  Use dynamic arrays  Write and read from files 1. WriteaclassGradeBookcontainingthefollowing: Private attributes: - courseName: a string representing the name of the course. - nbOfStudents: an integer representing the number of students enrolled in the course. The number of students is greater than or equal to 5. - grades: a double dimensional array of integers representing the grades of Test1, Test2 and Final of every student. It should be a dynamic array. Public...
1. You are to write a simple program with two classes. One controller class and a class to hold your object definition.
1. You are to write a simple program with two classes. One controller class and a class to hold your object definition. (Similar to what we used in class) 2. Use a package in your project, the package name should be xxxprojectname. xxx is your initials taken from the first three characters of your Cal Poly email address. 3. Read in the following from the JOptionPane input window: a. Customer First Name b. Customer Last Name c. Customer Phone Number...
Write a program that takes two sets ’A’ and ’B’ as input read from the file...
Write a program that takes two sets ’A’ and ’B’ as input read from the file prog1 input.txt. The first line of the file corresponds to the set ’A’ and the second line is the set ’B’. Every element of each set is a character, and the characters are separated by space. Implement algorithms for the following operations on the sets. Each of these algorithms must be in separate methods or subroutines. The output should be written in the file...
You will write classes from the last in-class assignment, R&DLibrary. R&DLibrary is the main file in...
You will write classes from the last in-class assignment, R&DLibrary. R&DLibrary is the main file in which a user can choose to enroll themselves, check out an item, return an item, pay a fine and display their account (what is currently checked out, accumulated fines). Write a material class that calculates the fine based off of the type of item, the length it’s been checked out and whether or not it’s even been checked out. Lastly, write a employee Class...
On a popular air route, an airline offers two classes of service: business class (B) and...
On a popular air route, an airline offers two classes of service: business class (B) and economy class (E). The respective inverse demands are given by PB = 540 - 0.5QB and PE = 380 - QE. Because of ticketing regulations, business passengers cannot take advantage of economy’s low fares. Each flight has a capacity of 200 passengers, The cost per full flight is $20,000, so you may assume the marginal cost per passenger is $100. 1. What is the...
Create 2 derived classes from Clothing class: Pants class Write only necessary constructors Override the wash()...
Create 2 derived classes from Clothing class: Pants class Write only necessary constructors Override the wash() method to indicate that pants are dry clean only. Include additional method hang() Add to your driver/tester file to make and print new pants objects and test it. Shirt class Include additional property of type string called sleeves. Write necessary constructors For sleeves only allow it to be set to {"short", "long", "none"} For size, only allow {"S","M","L"} Override the wash() method to indicate...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT