목록Activity (16)
BASHA TECH
Task You are given two classes, Person and Student, where Person is the base class and Student is the derived class. Completed code for Person and a declaration for Student are provided for you in the editor. Observe that Student inherits all the properties of Person. Complete the Student class by writing the following: A Student class constructor, which has parameters: A string, firstName. A st..
Task Calculate the hourglass sum for every hourglass in A, then print the maximum hourglass sum. Example In the array shown above, the maximum hourglass sum is 7 for the hourglass in the top left corner. Input Format There are 6 lines of input, where each line contains 6 space-separated integers that describe the 2D Array A. Constraints -9
Task Given a base-10 integer, n, convert it to binary (base-2). Then find and print the base-10 integer denoting the maximum number of consecutive 1's n's binary representation. When working with different bases, it is common to show the base as a subscript. Example n = 125 The binary representation of decimal number 125 is binary number 1111101. In base 10, there are 5 and 1 consecutive ones in..
Recursive Method for Calculating Factorial factorial(N) = 1 : N
Task Given n names and phone numbers, assemble a phone book that maps friends' names to their respective phone numbers. You will then be given an unknown number of names to query your phone book for. For each queried, print the associated entry from your phone book on a new line in the form name=phoneNumber; if an entry for name is not found, print Not found instead. Note: Your phone book should..
Task Given an array, A, of N integers, print A's elements in reverse order as a single line of space-separated numbers. Example A = [1, 2, 3, 4] Print 4 3 2 1. Each integer is separated by one space. Input Format The first line contains an integer, N (the size of our array). The second line contains N space-separated integers that describe array A's elements. Constraints Constraints 1
Task Given a string, S, of length N that is indexed from 0 to N - 1, print its even-indexed and odd-indexed characters as 2 space-separated strings on a single line (see the Sample below for more detail). Note: 0 is considered to be an even index. Example s = abdecf Print abc def Input Format The first line contains an integer, T (the number of test cases). Each line i of the T subsequent lines ..
Task Given an integer, n, print its first 10 multiples. Each multiple n x i (where 1
Task Write a Person class with an instance variable, age, and a constructor that takes an integer, initailAge, as a parameter. The constructor must assign to after confirming the argument passed as is not negative; if a negative argument is passed as initialAge, the constructor should set age to 0 and print Age is not valid, setting age to 0.. In addition, you must write the following instance m..
Task Given an integer, n, perform the following conditional actions: If n is odd, print Weird If n is even and in the inclusive range of 2 to 5, print Not Weird If n is even and in the inclusive range of 6 to 20, print Weird If n is even and greater than 20, print Not Weird Complete the stub code provided in your editor to print whether or not n is weird. Input Format A single line containing a ..