Secret Message - 1
Given a string, write a program to mirror the characters of the string in alphabetical order to create a secret message.
Note: Mirroring the characters in alphabetical order replacing the letters 'a' with 'z', 'b' with 'y', ... , 'z' with 'a'.
a b c d e f g h i j k l m
z y x w v u t s r q p o n
n o p q r s t u v w x y z
m l k j i h g f e d c b a
Input
The input will be a string in the single line containing spaces and letters (both uppercase and lowercase).
Output
The output should be a single line containing the secret message. All characters in the output should be in lower case.
Explanation
For example, if the given input is "python", "p" should replaced with "k", similarly "y" with "b", "t" with "g", "h" with "s", "o" with "l", "n" with "m". So the output should be "kbgslm".
Sample Input 1
python
Sample Output 1
kbgslm
Sample Input 2
Foundations
Sample Output 2
ulfmwzgrlmhAdd two polynomials
Given two polynomials A and B, write a program that adds the given two polynomials A and B
Output
Print the addition of polynomials A and B.
If the degree of polynomial is zero and the constant term is also zero, then just print 0 to represent the polynomial.
For term Cix^Pi, if the coefficient of the term Ci is 1, simply print x^Pi instead of 1x^Pi.Explanation
Hint:-
We can use dictionaries to maintain polynomial coeffients and powers.
Test Case 1:-
Input:-
6
0 -20
1 23
2 30
3 19
4 6
5 17
9
0 -100
5 -89
6 -20
7 -1
1 20
2 4
3 99
4 -45
8 12
Output:-
12x^8 - x^7 - 20x^6 - 72x^5 - 39x^4 + 118x^3 + 34x^2 + 43x - 120
Note :- Need Space between - and + operators
Test Case 2:-
Input:-
4
0 5
1 0
2 10
3 6
3
0 1
1 2
2 4
Output :-
6x^3 + 14x^2 + 2x + 6
Note:- Need Space between - and + operators
Test Case 3:-
Input:-
5
0 -2
3 6
4 7
1 -3
2 -1
5
0 1
1 2
2 -4
3 3
4 5
Output:-
12x^4 + 9x^3 - 5x^2 - x - 1
Note:- Need Space between - and + operators
We need all test cases can be came when code was run
Code a program to get the number of students and the group size from the user. Calculate and display the number of groups that must be used to divide the students in the given group size. The last group would possibly not be filled. Display also the number of students in the last group.
Functions to code and use:
Example:
If there are 23 students and they must be divided into groups of 6, then there will be 4 groups. The last group will have 5 members.
the logical structure in which one instruction occurs after another with no branching in java
Create a class named DogCare. Include fields for a dog’s data (using Dog class from question 1), the date (using Date class from question 4), the time (using Time class
The following code is supposed to display the positive even numbers less than 12. That is, it will output the numbers 2, 4, 6, 8 and 10. However, there is a logical error in the code. Explain what the output of the code below will be. Then write a small program including the code below and make the necessary changes to fix the code so that it displays what it is intended to display. Ensure that your program works correctly. Only submit the program, not the output. Hint: Use variable diagrams to trace the program to help you find the logical error. int x = 1; while (x != 12) { cout << x << endl; x = x + 2; }
A bookshop gives discount to customers as follows: Students get 10% discount, Book dealers get 12% discount and Pensioners get 15% discount. All other customers get 10% discount only if their total purchases are more than R200. You are requested to write two versions of a program that calculates and displays the final amount that is due, after discount. (i) The first version of the program uses a switch statement to implement the above program. (ii) The second version of the program uses nested-if statements. Hint: Use the following variables: float amount; // the amount due before discount char customerType; // the type of customer: 'S' (student) or // 'D' (dealer) or 'P' (pensioner) or // 'O'(other) float discount, finalAmount;
Include the for loop below in a small program and complete the program. The loop should execute 10 times. Do not change the for loop below. Compile and run your program to see for yourself that it works. You do not have to submit this program and output. for (int i = 1; i <= n; i++) cout << i * i; Now convert the for loop into a while loop and add any variable initialisations that you think are necessary. Compile and run your program and submit only the program containing the while loop and its output.
The Computer Science Department follows certain criteria when a student learns to program. A number of programming exercises must be worked through. To proceed to the next exercise a student has to obtain a mark of 50% or more and must have completed 5 or more program runs. You are requested to write a program to validate if a student can proceed to the next program. Your program should have the following structure: Declare two integer variables programsDone and result. Validate the data captured for the two variables using a while loop. The loop should be repeated until the value of result is greater than or equal to 50 and the value of programsDone is greater than or equal to 5. 20 Display a message like "Good! You can now proceed to the next exercise"
You are requested to write a very simple calculator. Your calculator should be able to handle the five basic mathematic operations – add, subtract, multiply, divide and modulus – on two input values. Your program should have the following structure: Ask the user to enter two float variables named var1 and var2 Ask the user to enter a character variable named operation to represent the operation to be performed on the two variables. Perform the appropriate operation by using if-statements The output must be given in fixed-point notation with two digits after the decimal point. A typical run is displayed below: Please enter the first float value: 35.6 Please enter the second value: 24.12 Please enter the operation required : + The sum of 35.6 and 24.12 is 59.72