Palindromic Numbers
A palindromic number is a positive integer that reads the same forward as backward. For example, the numbers 1, 11, and 121 are palindromic. Moreover, 1 and 11 are very special palindromic numbers: their squares are also palindromic. How many positive integers less than 10,000 have this property? Write a
The beginning part of your output should look like this:
1 has square 1
2 has square 4
3 has square 9
11 has square 121
22 has square 484
Hint: If str is a string object, the reverse () function (declared in <
reverse(str.begin(), str.end());
Want to see the full answer?
Check out a sample textbook solutionChapter 12 Solutions
Starting Out With C++: Early Objects (10th Edition)
Additional Engineering Textbook Solutions
Starting Out with Java: Early Objects (6th Edition)
Database Concepts (8th Edition)
Absolute Java (6th Edition)
Computer Science: An Overview (12th Edition)
Starting Out with Java: From Control Structures through Objects (6th Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
- QuadraticAA.java Write a program that solves quadratic equations of the form , where The values A, B, and C will be real numbers (doubles) that you will request from the user. The equation below is what is used to solve for . Remember, there will be two solutions for x (not necessarily distinct). No loops are necessary, so don’t include any. To find the two solutions for this equation, you will use the quadratic formula: Remember that it must be solved for both the and : You will ask the user to input a value for A, B, and C (in that order, using those same letters), then you will use those values to find the two values of x as above. Your output MUST then display the original quadratic equation back to the user with their coefficients in place, and then output the two results. We will assume that the user will not put zero for A. *Format ALL OUTPUT VALUES (including the equation) to have only two decimal places. There is a test case below. Your program should run the…arrow_forwardpython Geography Grades 2Make a copy of your program for the problem Geography Grades 1 and change the code in such a way that your program nolonger prints the average grade, but the final grade.The final grade is calculated by rounding the average grade to the nearest multiple of a half. So, for example, a 7.2becomes a 7.0 and 7.3 becomes a 7.5. If this calculation results in a 5.5, the final grade becomes a 6.0.Your assignment is to make the report for the geography course of group 2b, that, with the same example input as forthe problem Geography Grades 1, should look like this:Report for group 2bAnne Adema has a final grade of 6.0Bea de Bruin has a final grade of 7.0Chris Cohen has a final grade of 7.5Dirk Dirksen has a final grade of 4.5End of report"""arrow_forwardWrite a program that reads a sentence and store it in an array of characters. The program also reads a word and store in it a string variable. The program then conceals the word in the sentence with the character @'. Sample input / output: Enter a sentence: The town in which we live is a green town and big Enter a word: town Result: The @aa@ in which we live is a green @@@@ _and bigarrow_forward
- Using python, please explain 1: A positive integer greater than 1 is said to be prime if it has no divisors other than 1 and itself. A positive integer greater than 1 is composite if it is not prime. Write a program that asks the user to enter an integer greater than 1, then displays all of the prime numbers that are less than or equal to the number entered The program should work as follows: Once the user has entered a number, the program should populate a list with all of the integers from 2 up through the value entered. The program should then use a loop to step through the list. The loop should pass each element to a function that displays the element whether it is a prime number.arrow_forwardA contact list is a place where you can store a specific contact with other associated information such as a phone number, email address, birthday, etc. Write a program that first takes in word pairs that consist of a name and a phone number (both strings). That list is followed by a name, and your program should output the phone number associated with that name. Ex: If the input is: Joe 123-5432 Linda 983-4123 Frank 867-5309 Frank the output is: 867-5309 LAB 6.21.1: LAB: Contact list 0/ 10 ACTIVITY main.py Load default template... 1 user_input = input() 2 entries = user_input.split() 3 contact_list = dict(pair. split(':') for pair in entries)arrow_forwardPart 3: Negative Binary Numbers This standard method of binary number representation doesn't account for negative numbers. We can't just throw a negative sign in front of a binary number though - everything in a computer must be represented by 1's and 0's. One way we can get around this is by using the very first digit of each binary number to represent the sign: 0 for positive and 1 for negative. This is called 1's complement representation. 00010110 -> 0 0010110 -> positive 22 10010110 -> 1 0010110 -> negative 22 Using 1's complement representation we can represent the numbers -127 through 127 in a single byte (note that we can only go half as high as an unsigned number because half of the possible representations for that byte are being used for the negative numbers). However, there is a flaw with 1's complement: the representation of the number 0. 00000000 -> 0 0000000 -> zero 10000000 -> 1 0000000 -> negative zero? Because of this, we…arrow_forward
- language using - Javaarrow_forwardPrimeAA.java Write a program that will tell a user if their number is prime or not. Your code will need to run in a loop (possibly many loops) so that the user can continue to check numbers. A prime is a number that is only divisible by itself and the number 1. This means your code should loop through each value between 1 and the number entered to see if it’s a divisor. If you only check for a small handful of numbers (such as 2, 3, and 5), you will lose most of the credit for this project. Include a try/catch to catch input mismatches and include a custom exception to catch negative values. If the user enters 0, the program should end. Not only will you tell the user if their number is prime or not, you must also print the divisors to the screen (if they exist) on the same line as shown below AND give a count of how many divisors there are. See examples below. Your program should run the test case exactly as it appears below, and should work on any other case in general. Output…arrow_forwardC LANGUAGEarrow_forward
- Code in Java - While Loop Write a program that takes an integer and prints the number of trailing zeroes. Trailing zeroes are the zeroes found at the right side of a number.arrow_forwardPython:Write a program that prompts you to type an integer value and indicates whether the number is: Positive torqueOdd positiveNegative torqueNegative oddFor this exercise, consider the value 0 as a positive pair.arrow_forwardPython programming: A robot moves in a plane starting from the original point (0,0). The robot can move toward UP, DOWN, LEFT and RIGHT with a given steps. The trace of robot movement is shown as the following: UP 5 DOWN B LEFT B RIGHT 2 i The numbers after the direction are steps. Please write a program to compute the distance from current position after a sequence of movement and original point. If the distance is a float, then just print the nearest integer. Example: If the following tuples are given as input to the program: UP 5 DOWN 3 LEFT 3 RIGHT 2 Then, the output of the program should be: 2 Hints: In case of input data being supplied to the question, it should be assumed to be a console input.arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning