Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please i need help..We are coding in C++ using district unix.. I alos have some

ID: 3822864 • Letter: P

Question

Please i need help..We are coding in C++ using district unix.. I alos have some LList codes i could send if that would be helpful.....thanks

Note: Only Listing and Executions are required for this assignment. External Documentation is not required and should not be submitted for grading. However, you will still need to write complete 3-part Specifications (including a Program Description, Program Preconditions, and Program Postconditions) to include in the Overall Header Comment of your program Listing. Also, you will need to develop a set of at least 6 proposed normal testcases, 6 proposed boundary testcases, and 6 proposed exception testcases to run in your program Executions Most humans have 10 fingers. Therefore, long ago, when arithmetic was first being invented, humans tended to count with their 10 fingers, and this led to the system of decimal (base 10) arithmetic. Decimal arithmetic uses 10 decimal digits, which are the digits from 0 through 9 Most humans also have 10 toes. What if humans had invented an arithmetic system based on counting on their 10 fingers and 10 toes at the same time? Actually, some cultures did this (such as the ancient Mayans and Aztecs, and some current-day residents of Japan and Greenland), and this led to the development of vigesimal (base 20), arithmetic. Vigesimal arithmetic uses 20 vigesimal digits, which are the digits 0 through 9, as well as A ("ten''), B ("eleven''), C ("twelve"), D ("thirteen"), E ("fourteen"), F ("fifteen G ("sixteen"), H ("seventeen l ("eighteen and J ("nineteen

Explanation / Answer

//============================================================================
// Name        : base-converter.cpp
// Author      : Ramachandra jr
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <cstdlib>
#include <iostream>
#include "InVal.h"

using namespace std;

int main() {
   InVal num1{19, 10};
   num1.PrintAsBase(20);
   string some = "Hi there";

   int i{ 59 };

   for (; i; i /= 20 )
       cout << "i = " << i
           << ", i%20 = " << i%20
           << endl;


   return 0;
}

/*
* InVal.cpp
*
* Created on: 22-Apr-2017
*      Author: Rj
*/

#include "InVal.h"
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

InVal::InVal() : _num{ 0 }, _base{ 0 }
{};

InVal::InVal(int num, int base) : _num{ num }, _base{ base }
{}

InVal::~InVal()
{}

/**
* Converts the number stored in this object into given base.
*/
void InVal::PrintAsBase(int base)
{
   // String for storing the digits.
   // This string supports up to 20 digits.
   string digits("0123456789ABCDEFGHIJ");
   // Checks if this number is negative.
   bool is_neg = _num < 0;
   // A string for storing the result.
   string result;

   // While _num is not zero, in case it hits zero then then the condition willl be
   // evaluated to false and for loop will stop.
   for (; _num; _num /= base)
       // Do a modulo to get a relative digit according to long division.
       // Then abs to avoid negative values.
       // String.begin() gives you an iterator that points towards the first
       // character of the string.
       result.insert(result.begin(), digits[abs(_num % base)]);

   // If the number is negative insert a '-' sign in the result.
   if (is_neg)
       result.insert(result.begin(), '-');

   cout << result << endl;
};

/*
* InVal.h
*
* Created on: 22-Apr-2017
*      Author: Rj
*/

#ifndef INVAL_H_
#define INVAL_H_

class InVal {
private:
   int _num;
   int _base;

public:
   InVal();
   InVal(int num, int base);
   ~InVal();
   void PrintAsBase(int base);
};

#endif /* INVAL_H_ */