SlideShare uma empresa Scribd logo
1 de 3
Baixar para ler offline
COP3330 Programming Assignment 3 
The bigint class 
Objective 
1. Practice building class with operator overloading. 
Overview 
The native int type in C++ cannot store large integers of more than 10 decimal digits. In 
this project, you will implement a bigint class that behaves like the int type, but can 
handle unsigned integers of up to 45 digits. 
Details 
1. You are to build a class named bigint that can deal with up to 45 decimal digits of 
unsigned integers. The bigint class is specified as follows. 
2. The bigint class should have a five-element array (int v[5];) as its private date 
member. Each element should store 9 decimal digits. For example to store integer 
1,300,000,000,000,900,000,000,100,000,000. You should have v[0] = 100000000, 
v[1] = 900000000, v[2] =0, v[3]= 1300, and v[4] = 0. 
3. The bigint class should have the following constructors: 
bigint(); // default constructor, set the value to be 0 
bigint(int x0); // set the value to be x0 
bigint(int x0, int x1); // set the value to be x1*109+x0 
bigint(int x0, int x1, int x2); // set the value to be x2*1018+x1*109+x0 
bigint(int x0, int x1, int x2, int x3); 
bigint(int x0, int x1, int x2, int x3, int x4); 
4. To make bigint behave like int, you must overload the following operators 
a. The extraction operator >> for reading a bigint number from an input stream. 
The input number can have up to 45 digits. Following are two legitimate 
bigint numbers that can appear as input: 
1300000000000900000000100000000 
9999999999999999999999999999999999999999999 
b. The insertion operation << for output a bigint number to an output stream. 
The number must be output like a regular int number with the first digit 
being a non zero.
c. 2 arithmetic operators + and – (*, and / are omitted for this type to simplify 
the program). 
d. 6 comparison operators <, >, <=, >=, ==, and !=. 
5. Once the class is implemented, you can test your implementation using the 
proj3_driver.cpp program. You should also write other driver programs to do a 
thorough test of your bigint implementation. Put your bigint class declaration in 
proj3_bigint.h and your bigint class implementation in proj3_bigint.cpp. You should 
be able to compile the program by the command ‘g++ proj3_driver.cpp 
proj3_bigint.cpp’. Redirect proj3_test.txt as the standard input, the output of the 
program should be identical to proj3_test_out.txt. 
Submission 
The due time for this assignment is June 5 (Wendesday), 2013. 11:59pm. 
Tar all of your files for this assignment, which should include at least three files 
proj3_bigint.h, proj3_bigin.cpp, and bug_fixing_log.txt, name the tar file 
yourlastname_firstinitial_proj3.tar and submit the tar file in blackboard. The bug fixing 
log file must follow the template given in project 1. 
Grading policy 
The program must work on linprog. O point for programs with any g++ compiler error on 
linprog. You will need to track compiling errors that you fixed by yourselves in a log for 
fixed compiler bugs that needs to have at least two entries for 5 points/each entry (10 
points max) that are different from those in the bug fixing log in projects 1 and 2. 
· Program with no compiler error (20 points) 
· Log for fixed compiler bugs (10 points) 
· The default constructor and the overloaded << operator (20 points) 
· Other four constructors (3 points each, 12 points total) 
· Six comparison operators (2 points each, 12 points total) 
· + and – operators (8 points each, 16 point total) 
· The >> operator (10 points) 
Hints 
1. Start the project as soon as possible. 
2. You should first create proj3_bigint.h and have an empty implementation in 
proj3_bigint.cpp for each member and friend function with the body of the function 
containing one line
cout << “XXXX function has not been implemented.n” ; 
3. You should then compile the proj3_bigint.cpp and proj3_driver.cpp and run the 
code. From here, you can implement and test one function after another until the 
whole class is implemented. 
4. You should then implement the default construct, and write a simple operator<<() 
function that simply prints out the values of v[0], v[1], v[2], v[3], v[4]. 
5. After that you can implement the functions in the following order: the << operator, 
other constructors, the comparison operators, the arithmetic operators, and the >> 
operator. Remember to compile and run the program at least once everytime you 
add one function. 
6. To implement the << operator, you will need to output potentially 5 integers. You 
must use setw(9) and setfill(‘0’) to output each value besides the most significant 
non-zero integer. You must have ‘#include <iomanip>’ in the file in order to use 
these functions. The following line is an example to use these functions. 
s << setfile(‘0’) << setw(9) << vv.v[j]; 
7. To implement the >> operator, you can first read the string of digits into a character 
array and then manually convert it into a bigint number. 
8. To implement the + and – operators, you must pay special attention to the carry bit 
in the operations. 
9. To see the prototype of the overloaded operators (+, ==, >>, <<), check the examples 
in lecture 6.

Mais conteúdo relacionado

Mais procurados

Increment and Decrement operators in C++
Increment and Decrement operators in C++Increment and Decrement operators in C++
Increment and Decrement operators in C++Neeru Mittal
 
Write declarations for each of the following variables: a. amounts is a...
Write declarations for each of the following variables:       a. amounts is a...Write declarations for each of the following variables:       a. amounts is a...
Write declarations for each of the following variables: a. amounts is a...licservernoida
 
Infix-Postfix expression conversion
Infix-Postfix expression conversionInfix-Postfix expression conversion
Infix-Postfix expression conversionRashmiranja625
 
Prefix, Infix and Post-fix Notations
Prefix, Infix and Post-fix NotationsPrefix, Infix and Post-fix Notations
Prefix, Infix and Post-fix NotationsAfaq Mansoor Khan
 
Infix to Postfix Conversion Using Stack
Infix to Postfix Conversion Using StackInfix to Postfix Conversion Using Stack
Infix to Postfix Conversion Using StackSoumen Santra
 
Evaluation of postfix expression
Evaluation of postfix expressionEvaluation of postfix expression
Evaluation of postfix expressionAkhil Ahuja
 
Lecture 2 C++ | Variable Scope, Operators in c++
Lecture 2 C++ | Variable Scope, Operators in c++Lecture 2 C++ | Variable Scope, Operators in c++
Lecture 2 C++ | Variable Scope, Operators in c++Himanshu Kaushik
 
Programs that work in c and not in c
Programs that work in c and not in cPrograms that work in c and not in c
Programs that work in c and not in cAjay Chimmani
 
Infix postfixcoversion
Infix postfixcoversionInfix postfixcoversion
Infix postfixcoversionPdr Patnaik
 
Expression evaluation
Expression evaluationExpression evaluation
Expression evaluationJeeSa Sultana
 

Mais procurados (19)

Increment and Decrement operators in C++
Increment and Decrement operators in C++Increment and Decrement operators in C++
Increment and Decrement operators in C++
 
Conversion of Infix To Postfix Expressions
Conversion of Infix To Postfix Expressions Conversion of Infix To Postfix Expressions
Conversion of Infix To Postfix Expressions
 
Ankita sharma focp
Ankita sharma focpAnkita sharma focp
Ankita sharma focp
 
Type Casting in C++
Type Casting in C++Type Casting in C++
Type Casting in C++
 
Infix to postfix
Infix to postfixInfix to postfix
Infix to postfix
 
Write declarations for each of the following variables: a. amounts is a...
Write declarations for each of the following variables:       a. amounts is a...Write declarations for each of the following variables:       a. amounts is a...
Write declarations for each of the following variables: a. amounts is a...
 
Infix-Postfix expression conversion
Infix-Postfix expression conversionInfix-Postfix expression conversion
Infix-Postfix expression conversion
 
Prefix, Infix and Post-fix Notations
Prefix, Infix and Post-fix NotationsPrefix, Infix and Post-fix Notations
Prefix, Infix and Post-fix Notations
 
Infix to Postfix Conversion Using Stack
Infix to Postfix Conversion Using StackInfix to Postfix Conversion Using Stack
Infix to Postfix Conversion Using Stack
 
Evaluation of postfix expression
Evaluation of postfix expressionEvaluation of postfix expression
Evaluation of postfix expression
 
C++ ch2
C++ ch2C++ ch2
C++ ch2
 
Lecture 2 C++ | Variable Scope, Operators in c++
Lecture 2 C++ | Variable Scope, Operators in c++Lecture 2 C++ | Variable Scope, Operators in c++
Lecture 2 C++ | Variable Scope, Operators in c++
 
Operators in C & C++ Language
Operators in C & C++ LanguageOperators in C & C++ Language
Operators in C & C++ Language
 
Programs that work in c and not in c
Programs that work in c and not in cPrograms that work in c and not in c
Programs that work in c and not in c
 
Quiz 10 cp_sol
Quiz 10 cp_solQuiz 10 cp_sol
Quiz 10 cp_sol
 
Infix postfixcoversion
Infix postfixcoversionInfix postfixcoversion
Infix postfixcoversion
 
Tcs nqt 2019 p 1
Tcs nqt 2019 p 1Tcs nqt 2019 p 1
Tcs nqt 2019 p 1
 
C++ Ch3
C++ Ch3C++ Ch3
C++ Ch3
 
Expression evaluation
Expression evaluationExpression evaluation
Expression evaluation
 

Destaque

Destaque (17)

P4
P4P4
P4
 
Lo39
Lo39Lo39
Lo39
 
E7
E7E7
E7
 
Lo37
Lo37Lo37
Lo37
 
T2
T2T2
T2
 
P2
P2P2
P2
 
T4
T4T4
T4
 
T3
T3T3
T3
 
E10
E10E10
E10
 
Lo27
Lo27Lo27
Lo27
 
Lo17
Lo17Lo17
Lo17
 
Lo48
Lo48Lo48
Lo48
 
E8
E8E8
E8
 
P1
P1P1
P1
 
E9
E9E9
E9
 
T1
T1T1
T1
 
P5
P5P5
P5
 

Semelhante a P3

Programming For Engineers Functions - Part #1.pptx
Programming For Engineers Functions - Part #1.pptxProgramming For Engineers Functions - Part #1.pptx
Programming For Engineers Functions - Part #1.pptxNoorAntakia
 
Bottom of FormCreate your own FunctionFunctionsFor eac.docx
Bottom of FormCreate your own FunctionFunctionsFor eac.docxBottom of FormCreate your own FunctionFunctionsFor eac.docx
Bottom of FormCreate your own FunctionFunctionsFor eac.docxAASTHA76
 
OOP program questions with answers
OOP program questions with answersOOP program questions with answers
OOP program questions with answersQuratulain Naqvi
 
OOPS using C++
OOPS using C++OOPS using C++
OOPS using C++cpjcollege
 
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docxBTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docxAASTHA76
 
COMP 122 Entire Course NEW
COMP 122 Entire Course NEWCOMP 122 Entire Course NEW
COMP 122 Entire Course NEWshyamuopeight
 
HSc Computer Science Practical Slip for Class 12
HSc Computer Science Practical Slip for Class 12HSc Computer Science Practical Slip for Class 12
HSc Computer Science Practical Slip for Class 12Aditi Bhushan
 
Gsp 215 Believe Possibilities / snaptutorial.com
Gsp 215  Believe Possibilities / snaptutorial.comGsp 215  Believe Possibilities / snaptutorial.com
Gsp 215 Believe Possibilities / snaptutorial.comStokesCope20
 
python lab programs.pdf
python lab programs.pdfpython lab programs.pdf
python lab programs.pdfCBJWorld
 
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docxeugeniadean34240
 
Presentation 2 (1).pdf
Presentation 2 (1).pdfPresentation 2 (1).pdf
Presentation 2 (1).pdfziyadaslanbey
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 solIIUM
 
Basic Programming concepts - Programming with C++
Basic Programming concepts - Programming with C++Basic Programming concepts - Programming with C++
Basic Programming concepts - Programming with C++Mohamed El Desouki
 

Semelhante a P3 (20)

Programming For Engineers Functions - Part #1.pptx
Programming For Engineers Functions - Part #1.pptxProgramming For Engineers Functions - Part #1.pptx
Programming For Engineers Functions - Part #1.pptx
 
Bottom of FormCreate your own FunctionFunctionsFor eac.docx
Bottom of FormCreate your own FunctionFunctionsFor eac.docxBottom of FormCreate your own FunctionFunctionsFor eac.docx
Bottom of FormCreate your own FunctionFunctionsFor eac.docx
 
c++ referesher 1.pdf
c++ referesher 1.pdfc++ referesher 1.pdf
c++ referesher 1.pdf
 
2621008 - C++ 1
2621008 -  C++ 12621008 -  C++ 1
2621008 - C++ 1
 
OOP program questions with answers
OOP program questions with answersOOP program questions with answers
OOP program questions with answers
 
Cpp Homework Help
Cpp Homework Help Cpp Homework Help
Cpp Homework Help
 
OOPS using C++
OOPS using C++OOPS using C++
OOPS using C++
 
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docxBTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
 
COMP 122 Entire Course NEW
COMP 122 Entire Course NEWCOMP 122 Entire Course NEW
COMP 122 Entire Course NEW
 
HSc Computer Science Practical Slip for Class 12
HSc Computer Science Practical Slip for Class 12HSc Computer Science Practical Slip for Class 12
HSc Computer Science Practical Slip for Class 12
 
Gsp 215 Believe Possibilities / snaptutorial.com
Gsp 215  Believe Possibilities / snaptutorial.comGsp 215  Believe Possibilities / snaptutorial.com
Gsp 215 Believe Possibilities / snaptutorial.com
 
python lab programs.pdf
python lab programs.pdfpython lab programs.pdf
python lab programs.pdf
 
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
 
C++ Lab Maual.pdf
C++ Lab Maual.pdfC++ Lab Maual.pdf
C++ Lab Maual.pdf
 
C++ Lab Maual.pdf
C++ Lab Maual.pdfC++ Lab Maual.pdf
C++ Lab Maual.pdf
 
Presentation 2 (1).pdf
Presentation 2 (1).pdfPresentation 2 (1).pdf
Presentation 2 (1).pdf
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 sol
 
Basic Programming concepts - Programming with C++
Basic Programming concepts - Programming with C++Basic Programming concepts - Programming with C++
Basic Programming concepts - Programming with C++
 
Bcsl 031 solve assignment
Bcsl 031 solve assignmentBcsl 031 solve assignment
Bcsl 031 solve assignment
 
C++ Homework Help
C++ Homework HelpC++ Homework Help
C++ Homework Help
 

Mais de lksoo

Mais de lksoo (13)

Lo43
Lo43Lo43
Lo43
 
Lo12
Lo12Lo12
Lo12
 
L10
L10L10
L10
 
L9
L9L9
L9
 
L8
L8L8
L8
 
L7
L7L7
L7
 
L6
L6L6
L6
 
L5
L5L5
L5
 
L4
L4L4
L4
 
L3
L3L3
L3
 
L2
L2L2
L2
 
L1
L1L1
L1
 
E6
E6E6
E6
 

Último

Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 

Último (20)

Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 

P3

  • 1. COP3330 Programming Assignment 3 The bigint class Objective 1. Practice building class with operator overloading. Overview The native int type in C++ cannot store large integers of more than 10 decimal digits. In this project, you will implement a bigint class that behaves like the int type, but can handle unsigned integers of up to 45 digits. Details 1. You are to build a class named bigint that can deal with up to 45 decimal digits of unsigned integers. The bigint class is specified as follows. 2. The bigint class should have a five-element array (int v[5];) as its private date member. Each element should store 9 decimal digits. For example to store integer 1,300,000,000,000,900,000,000,100,000,000. You should have v[0] = 100000000, v[1] = 900000000, v[2] =0, v[3]= 1300, and v[4] = 0. 3. The bigint class should have the following constructors: bigint(); // default constructor, set the value to be 0 bigint(int x0); // set the value to be x0 bigint(int x0, int x1); // set the value to be x1*109+x0 bigint(int x0, int x1, int x2); // set the value to be x2*1018+x1*109+x0 bigint(int x0, int x1, int x2, int x3); bigint(int x0, int x1, int x2, int x3, int x4); 4. To make bigint behave like int, you must overload the following operators a. The extraction operator >> for reading a bigint number from an input stream. The input number can have up to 45 digits. Following are two legitimate bigint numbers that can appear as input: 1300000000000900000000100000000 9999999999999999999999999999999999999999999 b. The insertion operation << for output a bigint number to an output stream. The number must be output like a regular int number with the first digit being a non zero.
  • 2. c. 2 arithmetic operators + and – (*, and / are omitted for this type to simplify the program). d. 6 comparison operators <, >, <=, >=, ==, and !=. 5. Once the class is implemented, you can test your implementation using the proj3_driver.cpp program. You should also write other driver programs to do a thorough test of your bigint implementation. Put your bigint class declaration in proj3_bigint.h and your bigint class implementation in proj3_bigint.cpp. You should be able to compile the program by the command ‘g++ proj3_driver.cpp proj3_bigint.cpp’. Redirect proj3_test.txt as the standard input, the output of the program should be identical to proj3_test_out.txt. Submission The due time for this assignment is June 5 (Wendesday), 2013. 11:59pm. Tar all of your files for this assignment, which should include at least three files proj3_bigint.h, proj3_bigin.cpp, and bug_fixing_log.txt, name the tar file yourlastname_firstinitial_proj3.tar and submit the tar file in blackboard. The bug fixing log file must follow the template given in project 1. Grading policy The program must work on linprog. O point for programs with any g++ compiler error on linprog. You will need to track compiling errors that you fixed by yourselves in a log for fixed compiler bugs that needs to have at least two entries for 5 points/each entry (10 points max) that are different from those in the bug fixing log in projects 1 and 2. · Program with no compiler error (20 points) · Log for fixed compiler bugs (10 points) · The default constructor and the overloaded << operator (20 points) · Other four constructors (3 points each, 12 points total) · Six comparison operators (2 points each, 12 points total) · + and – operators (8 points each, 16 point total) · The >> operator (10 points) Hints 1. Start the project as soon as possible. 2. You should first create proj3_bigint.h and have an empty implementation in proj3_bigint.cpp for each member and friend function with the body of the function containing one line
  • 3. cout << “XXXX function has not been implemented.n” ; 3. You should then compile the proj3_bigint.cpp and proj3_driver.cpp and run the code. From here, you can implement and test one function after another until the whole class is implemented. 4. You should then implement the default construct, and write a simple operator<<() function that simply prints out the values of v[0], v[1], v[2], v[3], v[4]. 5. After that you can implement the functions in the following order: the << operator, other constructors, the comparison operators, the arithmetic operators, and the >> operator. Remember to compile and run the program at least once everytime you add one function. 6. To implement the << operator, you will need to output potentially 5 integers. You must use setw(9) and setfill(‘0’) to output each value besides the most significant non-zero integer. You must have ‘#include <iomanip>’ in the file in order to use these functions. The following line is an example to use these functions. s << setfile(‘0’) << setw(9) << vv.v[j]; 7. To implement the >> operator, you can first read the string of digits into a character array and then manually convert it into a bigint number. 8. To implement the + and – operators, you must pay special attention to the carry bit in the operations. 9. To see the prototype of the overloaded operators (+, ==, >>, <<), check the examples in lecture 6.