SlideShare a Scribd company logo
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.

More Related Content

What's hot

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
 
Conversion of Infix To Postfix Expressions
Conversion of Infix To Postfix Expressions Conversion of Infix To Postfix Expressions
Conversion of Infix To Postfix Expressions
Kulachi Hansraj Model School Ashok Vihar
 
Ankita sharma focp
Ankita sharma focpAnkita sharma focp
Ankita sharma focp
AnkitaSharma463389
 
Infix to postfix
Infix to postfixInfix to postfix
Infix to postfix
Saeed Farooqi
 
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 conversion
Rashmiranja625
 
Prefix, Infix and Post-fix Notations
Prefix, Infix and Post-fix NotationsPrefix, Infix and Post-fix Notations
Prefix, Infix and Post-fix Notations
Afaq Mansoor Khan
 
Infix to Postfix Conversion Using Stack
Infix to Postfix Conversion Using StackInfix to Postfix Conversion Using Stack
Infix to Postfix Conversion Using Stack
Soumen Santra
 
Evaluation of postfix expression
Evaluation of postfix expressionEvaluation of postfix expression
Evaluation of postfix expression
Akhil Ahuja
 
C++ ch2
C++ ch2C++ 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++
Himanshu Kaushik
 
Operators in C & C++ Language
Operators in C & C++ LanguageOperators in C & C++ Language
Operators in C & C++ Language
PreSolutions Softwares
 
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
Ajay Chimmani
 
Infix postfixcoversion
Infix postfixcoversionInfix postfixcoversion
Infix postfixcoversion
Pdr Patnaik
 
Tcs nqt 2019 p 1
Tcs nqt 2019 p 1Tcs nqt 2019 p 1
Tcs nqt 2019 p 1
Phaneendra Bolla
 
C++ Ch3
C++ Ch3C++ Ch3
Expression evaluation
Expression evaluationExpression evaluation
Expression evaluation
JeeSa Sultana
 

What's hot (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
 

Viewers also liked

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

Viewers also liked (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
 

Similar to 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.pptx
NoorAntakia
 
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
AASTHA76
 
c++ referesher 1.pdf
c++ referesher 1.pdfc++ referesher 1.pdf
c++ referesher 1.pdf
AnkurSingh656748
 
OOP program questions with answers
OOP program questions with answersOOP program questions with answers
OOP program questions with answers
Quratulain Naqvi
 
Cpp Homework Help
Cpp Homework Help Cpp Homework Help
Cpp Homework Help
C++ Homework Help
 
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.docx
AASTHA76
 
COMP 122 Entire Course NEW
COMP 122 Entire Course NEWCOMP 122 Entire Course NEW
COMP 122 Entire Course NEW
shyamuopeight
 
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
Aditi Bhushan
 
Gsp 215 Believe Possibilities / snaptutorial.com
Gsp 215  Believe Possibilities / snaptutorial.comGsp 215  Believe Possibilities / snaptutorial.com
Gsp 215 Believe Possibilities / snaptutorial.com
StokesCope20
 
python lab programs.pdf
python lab programs.pdfpython lab programs.pdf
python lab programs.pdf
CBJWorld
 
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
eugeniadean34240
 
C++ Lab Maual.pdf
C++ Lab Maual.pdfC++ Lab Maual.pdf
C++ Lab Maual.pdf
Thejeswara Reddy
 
C++ Lab Maual.pdf
C++ Lab Maual.pdfC++ Lab Maual.pdf
C++ Lab Maual.pdf
ShivamParjapati2
 
Presentation 2 (1).pdf
Presentation 2 (1).pdfPresentation 2 (1).pdf
Presentation 2 (1).pdf
ziyadaslanbey
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 sol
IIUM
 
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
 
Bcsl 031 solve assignment
Bcsl 031 solve assignmentBcsl 031 solve assignment
C++ Homework Help
C++ Homework HelpC++ Homework Help
C++ Homework Help
C++ Homework Help
 

Similar to 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
 

More from lksoo

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

More from 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
 

Recently uploaded

Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 

Recently uploaded (20)

Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 

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.