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...
Write two classes, ToDoList and Driver ToDoList should implement the following UML class diagram: ToDoList -list:String[]...
Write two classes, ToDoList and Driver ToDoList should implement the following UML class diagram: ToDoList -list:String[] -size:int +ToDoList() +add(String item):void +remove(String item): boolean +toString():String add(String item) should add the item as the last element in the list, updating size. remove(String item) should remove the item and return true, or, if the item was not in the list, return false.   To remove the item, check every list element from 0 to size-1, and if that item is equal to the parameter...
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...
Write a C++ program that takes two sets ’A’ and ’B’ as input read from the...
Write a C++ 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...
Write a C++ program that takes two sets ’A’ and ’B’ as input read from the...
Write a C++ 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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT