Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this assignment, you will need to implement addition (same signs only) and multiplication using strings (C++). If you right-click the images and open them

For this assignment, you will need to implement addition (same signs only) and multiplication using strings (C++). If you right-click the images and open them on a new tab they are visible.

image text in transcribedimage text in transcribedimage text in transcribed

GIGrasp 41 - GRASP CSD (C) File Edit View Build Project Settings Tools Window Help EX All Files Sort By C:1 Intel PertLogs Program Files Program Files (x86) Riot Games Users Windows abtext.txt NvContainer RecoveryNvCor NvContainerRecoveryNVDIE 1 fndef STRING CALCULATOR H 2 #define STRING CALCULATOR H 3 4 include 5 6/ 7 convert a character digit to an integer value 8 Input: digit a character representing a digit, e. '' 9.output the corresponding Integer value of the digit, e.: 7 10 throus: std::invalid argument if the input is not a valid digit, e.g. '' -- '9* 11 / 12 unsigned int digit_to_decimal(char digit); 13 14 / 15 convert an integer value to a character digit 16 input: decinal - an integer value of a digit. 4.87 17 output the corresponding character of the digit, e.g. 17* 18 throws: std::invalid argument if the input is not a valid digit, 2.8. - 9 19 / 20 char decimal_to_digit(unsigned int decimal) 21 22 / 23 remove the leading zeros from a number 24 Input: nun - a string representing a number with zero or more leading as 25 output: a copy of the input with all leading es removed 26 throws none 27 28 std::string trim_leading_zeros(std::string num); 29 30 / 31 add the numbers 32 Input: Ihs, rhs - strings representing numbers, e.g: "1", "2" 33 output: the result of adding rhs to lhs: 1ks - rhs .. 13" 34 throws none. 35 / 36 std::string add(std::string lhs, std::string rhs): 37 38/" 39 suplity two numbers 40 input: lhs, rhs - strings representing numbers, c.e: "1", "2" 41 output: the result of multiplying Ihs by th: Ihsrhs, e.g. 42 throws! none. 43 / 44 std::string multiply(std::string lhs, std::string rha); 45 46 #endif // STRING_CALCULATOR_L zybooks.cpp G string calculator Grasp 4 Compile Messages GRASP Messages Run Interactions Clear Copy Browse Find Debug Workbench Line:46 Col:31 Code:0 Top:1 4 main.cpp 2 string, cactor.com #include #include #include #include #include "/string_calculator.h" 4 6 using std::cout, std::endi, std::cin; using std::string; 8 9 10 11 12 13 14 int main() { cout #include #include #include "./string_calculator.h" using std::cout, std::endl; using std::string; unsigned int digit_to_decimal(char digit) { 7 TODO(student): implement return 0; 3 1 2 3 4 5 6 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 char decimal_to_digit(unsigned int decimal) { // TODO(student): implement return 'le; ) string trim_leading_zeros(string num) { // TODO(student): Implement return **; } string add(string lhs, string rhs) { // TODO (student) implement return; } string multiply(string lhs, string rhs) { // TODO(student). Implement return; } Le 3 Column 1 Sos: 4 C++ GIGrasp 41 - GRASP CSD (C) File Edit View Build Project Settings Tools Window Help EX All Files Sort By C:1 Intel PertLogs Program Files Program Files (x86) Riot Games Users Windows abtext.txt NvContainer RecoveryNvCor NvContainerRecoveryNVDIE 1 fndef STRING CALCULATOR H 2 #define STRING CALCULATOR H 3 4 include 5 6/ 7 convert a character digit to an integer value 8 Input: digit a character representing a digit, e. '' 9.output the corresponding Integer value of the digit, e.: 7 10 throus: std::invalid argument if the input is not a valid digit, e.g. '' -- '9* 11 / 12 unsigned int digit_to_decimal(char digit); 13 14 / 15 convert an integer value to a character digit 16 input: decinal - an integer value of a digit. 4.87 17 output the corresponding character of the digit, e.g. 17* 18 throws: std::invalid argument if the input is not a valid digit, 2.8. - 9 19 / 20 char decimal_to_digit(unsigned int decimal) 21 22 / 23 remove the leading zeros from a number 24 Input: nun - a string representing a number with zero or more leading as 25 output: a copy of the input with all leading es removed 26 throws none 27 28 std::string trim_leading_zeros(std::string num); 29 30 / 31 add the numbers 32 Input: Ihs, rhs - strings representing numbers, e.g: "1", "2" 33 output: the result of adding rhs to lhs: 1ks - rhs .. 13" 34 throws none. 35 / 36 std::string add(std::string lhs, std::string rhs): 37 38/" 39 suplity two numbers 40 input: lhs, rhs - strings representing numbers, c.e: "1", "2" 41 output: the result of multiplying Ihs by th: Ihsrhs, e.g. 42 throws! none. 43 / 44 std::string multiply(std::string lhs, std::string rha); 45 46 #endif // STRING_CALCULATOR_L zybooks.cpp G string calculator Grasp 4 Compile Messages GRASP Messages Run Interactions Clear Copy Browse Find Debug Workbench Line:46 Col:31 Code:0 Top:1 4 main.cpp 2 string, cactor.com #include #include #include #include #include "/string_calculator.h" 4 6 using std::cout, std::endi, std::cin; using std::string; 8 9 10 11 12 13 14 int main() { cout #include #include #include "./string_calculator.h" using std::cout, std::endl; using std::string; unsigned int digit_to_decimal(char digit) { 7 TODO(student): implement return 0; 3 1 2 3 4 5 6 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 char decimal_to_digit(unsigned int decimal) { // TODO(student): implement return 'le; ) string trim_leading_zeros(string num) { // TODO(student): Implement return **; } string add(string lhs, string rhs) { // TODO (student) implement return; } string multiply(string lhs, string rhs) { // TODO(student). Implement return; } Le 3 Column 1 Sos: 4 C++

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions

Question

Explain the meaning and significance of the contribution margin .

Answered: 1 week ago

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago