[Solved] CSE102 Homework 2

$25

File Name: CSE102_Homework_2.zip
File Size: 160.14 KB

SKU: [Solved] CSE102 Homework 2 Category: Tag:
5/5 - (1 vote)

Write a complete program describing all the tasks below. In the main () function, the 3 integer values requested from the user will represent the lengths of the sides of a triangle, and the 4 functions specified below will be called from the main ( ) function, ensuring that all tasks are performed completely.

Determining whether the triangle can be drawn according to the triangle inequality theorem.

  • If the triangle cannot be drawn;
    • According to the triangle inequality theorem, this triangle cannot be drawn. message should be printed on the screen and the process should end.
  • If the triangle can be drawn;
    • According to the triangle inequality theorem, this triangle can be drawn. message should be printed on the screen
    • the type of triangle should be determined
    • the perimeter of the triangle should be calculated the area of the triangle should be calculated
  1. Write a function that determines whether the triangle can be drawn according to the triangle inequality theorem and returns 1 if it can be plotted and 0 if it cannot be drawn.

The Triangle Inequality Theorem states that the sum of any 2 sides of a triangle must be greater than the measure of the third side.

Function prototype is int draw_triangle(int side1,int side2, int side3)

  1. Write a function that determines the type of the triangle (equilateral, isosceles or scalene) and prints on the screen, without returning value.

Function prototype is void type_triangle(int side1,int side2, int side3)

  1. Write a function that calculates the perimeter of the triangle and returns this value.

Function prototype is int perimeter_triangle(int side1,int side2, int side3)

  1. Write a function that calculates the area of the triangle according to the formula below and returns this value.

Function prototype is double area_triangle(int side1,int side2, int side3,int perimeter)

Tip: When calculating the area of the triangle, take root by using the sqrt () function of the math library. You can find detailed information about using this function here.

Part 2.

In the main ( ) function, ask the user to enter a maximum of 6 digits and consider this number written 100 times next to each other. Write a complete program that tries to find the number in an index to be determined by the user in this large series of numbers.

Please note that the integer array and loops will not be used in the question.

You are expected to use 2 functions except the main function while performing the desired operations in the question.

  1. A function that finds the length of the number entered by the user on the command screen and returns the integer value expressing the length should be defined.

Function prototype is int number_length(int number)

Hint : You can use the logarithm to find out how many digits the number is. You can access log functions and their uses in the math library for logarithm operation from here.

  1. According to the index value entered by the user on the command screen, define a function that finds the number in the specified index and returns that integer value.

Function prototype is int find_digit(int number, int index)

Hint : In order to obtain the number in a certain index within the number, you should use the digit values of the number. You may need the powers of 10 in your mathematical calculation. In this case, you can find detailed information about using pow () function in the math library here.

Part 3.

Write a currency converter program in the Main () function. You do not have to define functions for this part.

Exchange rate information will be accepted as follows.

1 Euro = 6.69 Turkish Lira

1 Dollar = 6.14 Turkish Lira

As you can see the screen output below, the user must first be greeted with the message ***** Welcome to ABC Exchange Office *****.

Then the user should be asked to write the amount of money he/she has on the command screen. The menu in the screenshot below should be created in order to select the currency that the user has.

By using the switch case structure according to the users choice;

For example, if the user chose 1, You have xxx Turkish Liras message should be printed on the screen.

Then, the user should be asked to choose the rate he / she wants to convert according to the menu above.

Currency exchange calculations should be completed depending on the users choice again.

Please note that when the user makes a wrong choice (for example, if he makes a choice of 5), Your selection is invalid. message should be printed.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSE102 Homework 2
$25