Purpose: To practice writing a simple well-documented (lots of comments) C++ program using
repetition structures (loops).

Assignment: The power of a repetition structure lies in the fact that a section of code can
be executed several times (often using different data) in the same program run.

Modify, Laboratory Assignment # 3 so that it will perform integer division using
different sets of values during a single program run. In each set, the first value is
the dividend and the second value is the divisor. You may use either a while or a
do-while sentinel-controlled repetition structure. A for structure may not be used.

Test your program by reading in integer values from a data file that I will send you.
The sentinel value is -99.

Be sure to print out the dividend and divisor values along with the quotient and
remainder for each set of values. The program output should go to a .dat output file
as well as to the computer monitor.

Recommended Answers

All 10 Replies

So you want someone to do your homework for you.... I can help you write a division calculator with loops and stuff but i am not gonna write it for you..

So you want someone to do your homework for you.... I can help you write a division calculator with loops and stuff but i am not gonna write it for you..

That's fine... i need all the help i can get.

Funny thing is that you just copy pasted your assignment without even posting assignment #3 which is referred to in this one.

Post what you have so far (and not the original assignment #3) and say what you need help with.

Funny thing is that you just copy pasted your assignment without even posting assignment #3 which is referred to in this one.

Post what you have so far (and not the original assignment #3) and say what you need help with.

Here is Assignment 3
Assignment # 3 – if Selection Structures (Integer Division) -- modified

Purpose: To practice writing a simple well-documented (lots of comments) C++ program using the if and/or if/else selection structures.

Assignment: Computers are not able to properly calculate division problems that have a divisor of value 0. Modify, Laboratory Assignment # 2 so that it will test the value of the divisor before performing the integer division. In the case that the divisor is zero,the program should print an error message; otherwise, the program should perform the division.
Test your program by reading in any integer value for the dividend and zero (0) for the divisor.

I just said post your code and NOT just assignment #3.

Show us some effort that you actually tried to do this. Don't just copy and paste your homework! Programmers hate it and most likely no-one will help. Try to do it on your own and you you have any problems we will help you!

#include <iostream>

using namespace std;


int main(){

    char cDog;

    do{





        float div;
        float divs;

        cout << " Enter Num1: " << endl;
        cin >> div;
        cout << "Enter Num2: " << endl;
        cin >> divs;
        cout << div / divs << endl;
        cout << "WOuld You like to continue? Y/N: " << endl;
        cin >> cDog;

    }while (cDog == 'Y' || cDog == 'y');



    system("PAUSE");

    return 0;

}

This is a very basic C++ console div calculator i wrote up in about 3 min it uses a while loop this is i have time to write for you i am not writing a GUI

commented: code tags maybe? and where did GUI come from? -1

I just said post your code and NOT just assignment #3.

#include <iostream>

using namespace std;

int main() {
// Declare inputs
int dividend, divisor;
// Declare outputs
int quotient, remainder;

// Acquire the inputs
cout << "Please input the dividend: ";
cin >> dividend;
cout << "Please input the divisor: ";
cin >> divisor;

// Validate input
if ( divisor == 0 ) {
cout << "Error! Divide by zero!" << endl;
return -1;
}

// Calculate
quotient = dividend / divisor;
remainder = dividend - quotient * divisor;

// Output results
cout << "Quotient: " << quotient << endl;
cout << "Remainder: " << remainder << endl;

return 0;

You need to somehow determine what the input file is like through arguments or cin, and then write a loop around the calculations that reads the data from the file until the sentinel value is reached.

It looks to me like you just posted the code from that assignment #3 of yours and didn't even try at this one.

i have a presentation on this monday,i dont know what idea how should i present about the CAR PAR MACHINE..i must write it in C++..that progrm should have a looping,selection n sequence..someone please help me...give me an idea..huhuh

commented: Start by making your own thread, and improving your spelling. -1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.