Sale!

CS2310 Assignment One Solved

Original price was: $40.00.Current price is: $35.00. $29.75

Category:

Description

5/5 - (3 votes)

CS2310 Assignment One

Q1 Write a program that meets all the following requirements

1. Receive two inputs:

a. An integer representing the size of the arrow (“” or “”) to print. In particular, it represents the length of the central line to be printed out. Note that you can assume the input integer is always not less than 4.

b. A character that indicates the direction of the arrow, i.e., “” or “”. If the character is ‘U’, then output the shape of “”; if the character is D, output the shape of “”. For the input other than ‘U’ and ‘D’, the program will print “Invalid input!” and terminate.

2. We assume that the arrow is made up of the symbol ‘*’. The length of an arrow is measured by the number of ‘*’. The number of ‘*’ on each edge of the arrow is defined as ⌊1/2 ∙ length⌋, e.g., if length = 7, size(edge)=3 (as shown below); if length = 9, size(edge) = 4.

Some running samples are given below. Sample 1: Sample 2: Sample 3:

Q2. Write a program to print the pattern made up of two hollow triangles. The program receives as input an integer and then prints the pattern based on the integer. Note that the input integer value is required to be not less than 3.

So, the program should keep doing validity check until the input integer is a valid one. This integer represents the number of rows occupied by a hollow triangle. Some running samples are given below: Sample 1: Sample 2: Sample 3:

CS2310 Assignment One