Line Segment

  1. Write a program that reads in two distinct positive integers. The program prints the difference between the larger number and the smaller one. Be sure that the program will print 6 both when 9 and 15 are read and when 15 and 9 are read. In other words, the program displays the difference between these two positive numbers, regardless of which one is larger.
  2. Write a program that reads in a character and a positive integer. If the character is a digit character, (i.e. ‘0’, ‘1’, …, ‘9’), the program prints the square root of the integer; otherwise, it prints the square of the integer. For example, if the character entered is 5 (which should be read in as char type, but the users enter 5 instead of ‘5’) and the integer value entered is 25, then the program displays the value 5, which is the square root of 25. On the other hand, if the character entered is c and the integer value is 8, then the program displays the value of 64, which is the square of 8.
  3. The fans of Tuskegee University Golden Tiger basketball team want to know whether or not the team had a winning season for the 2016-2017 season. Write a program to read the number of wins and the number losses that the Golden Tigers had in the season. The program then prints a message “What a season!!!” if Golden Tigers had a winning season; otherwise, it prints “More practice needed.” For example, if the number of wins is 18 and the number of losses is 12, the program displays the message What a season!!!. On the other hand, if the number of wins is 12 and the number of losses is 18, then the message More practice needed is displayed by the program.
  4. Write a program that reads a temperature reading and a character code. If the character code is ‘C’, the temperature reading is in Celsius; otherwise, the temperature reading is in Fahrenheit. If the character code is ‘C’, the program converts the temperature reading from Celsius to Fahrenheit; otherwise, it converts the temperature reading from Fahrenheit to Celsius. The output of the conversion should look like:

xxx.xx degrees Fahrenheit = yyy.yy degrees Celsius

or

xxx.xx degrees Celsius = yyy.yy degrees Fahrenheit

where xxx.xx is the temperature reading entered by the user and yyy.yy is converted temperature. Both degrees are displayed in 2 decimal places.

5. Write a program that reads two points representing a line segment. Each point is represented by x and y coordinates – (x, y). If the slope of the line passing through those two points exists, the program calculates and prints the slope of the line; otherwise, it prints a message indicating the slope does not exist. Hint: The slope of a line segment may be positive, zero, negative, or does not exist. Refer to the MATH 107 textbook or the Internet to find how to calculate the slope of a line segment passing through two points.

Do you need help with this assignment? Or a different one? We got you covered.

Quality Guaranteed

Any Deadline

No Plagiarism