Sale!

CSED 232 Programming Assignment #1 Solved

Original price was: $35.00.Current price is: $30.00.

Download Details:

  • Name: assn1-my15h3.zip
  • Type: zip
  • Size: 193.62 KB

Category:

Description

Rate this product

. Program function – 50% l Does the program run properly while satisfying all requirements? 2. Program design and implementation – 35% l Are the variables and algorithms designed well to satisfy the requirements? l Have all the notes on the detailed conditions presented in each problem been satisfied? l Does the program operate properly in the given input and output format? 3. Program readability – 5% l Is the program written in a way that is easy to read and understand? l Is it easy to understand what the variable names mean? l Is the program’s source code well-commented to make it easy to understand? 4. Report Structure, Content, and Format – 10% l Is the report well-written, easy to understand, and easy to read, with appropriate content? l Did it follow the report format? l If there are questions posed in each question, are the answers sufficient? [Note] Simply copying or modifying someone else’s program or a program found on the Internet and submitting it is considered cheating. If cheating is discovered, you will receive an ‘F’ grade, and there may be additional penalties depending on the department’s standards. Question 1 (30 points) Junyoung, a student at Pohang University of Science and Technology , decided to create a program to convert a given decimal number to binary (or octal, hexadecimal) during winter break before taking an object-oriented programming class . When given a decimal number and a base to be converted, output the correct execution result. [Input] A decimal number and a base to be converted are given as int type. [Output] Represents the given decimal number as the base to be converted. [Detailed conditions] 1. std::hex and std::oct cannot be used. [Input/Output Example] input output 119 2 119 8 119 16 1110111 167 77 Problem 2 (30 points) Minsu, a student at Pohang University of Science and Technology, is creating a calculator program during winter vacation. The calculator Minsu is supposed to create is a calculator that can perform six operations: ‘+’, ‘-‘, ‘*’, ‘/’, ‘sqrt’, and ‘square’. Take an operation and two numbers as input and output the result of the operation correctly. In this case, only one number is given for the sqrt and square operations. [Input] 1. The operator is a char (array) data type, and the two numbers are a float data type.

2. The operators that the calculator can accept are ‘+’, ‘-‘, ‘*’, ‘/’, ‘sqrt’, and ‘square’, which represent addition,
subtraction, multiplication, division, square root (√
!
), and exponentiation (!), respectively.
3. There is a space between the operator and each number.
[Output]
The calculation result is output correctly based on the given input.
[Detailed conditions]
2. If the calculation result is longer than three decimal places, it is rounded to the third decimal place and output.
ex) 3.986 ∗ 2.515 = 10.02479 ≅ 10.025 (Rounded to the third decimal place)
3. The situation where 0 is entered as the second digit of the input is not considered.
4. If it is an integer, it does not need to be expressed as a decimal.
[Input/Output Examples]
input output
+ 1.35 2.47
* 3.986 2.515
/ 24.999 3.900
– -101.35 2.47
square 4
sqrt 4
3.820
10.025
6.410
-103.820
16
2
Problem 3 (40 points)
Pohang University of Science and Technology students Junyoung and Minsu
want to create an integrated calculator program based on the programs they each created during winter vacation (Problem 1, Problem 2). The program they want to create
takes two numbers (binary, octal, or hexadecimal) and an operation as input, and outputs them in decimal.
Take the operation and two numbers as input, and output the operation result correctly.
[Input]
1. The operator is char type, and the number is std::string type as input. At this time, the two numbers are binary,
octal, or hexadecimal. Each base number is expressed by attaching ‘0b’, ‘0’, and ‘0X’ to the front of the number. For example,
hexadecimal can be expressed as 0b1001, 020, and 0X2F. 2. The operations that the calculator can accept are ‘+’, ‘-‘, ‘*’, and ‘/’, which represent
addition, subtraction, multiplication, and division, respectively . 3. There is a space between the operator and each number. [Output] Based on the given input, the calculation result is output in decimal. [Detailed conditions] 1. If the calculation result is longer than three decimal places, it is rounded to the third decimal place and output. 2. The situation where 0 is entered as the second digit of the input is not considered. 3. If it is an integer, it does not need to be expressed as a decimal. 4. Negative numbers or decimals are not entered as input. [Input/Output Example] input output + 0X52 0b1000 – 070 0XF * 0b10 031 / 0XFF 032 90 41 50 9.808