We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>

Looking For Something at vustudents.ning.com? Click Here to Search

www.bit.ly/vucodes

+ Link For Assignments, GDBs & Online Quizzes Solution

www.bit.ly/papersvu

+ Link For Past Papers, Solved MCQs, Short Notes & More


Dear Students! Share your Assignments / GDBs / Quizzes files as you receive in your LMS, So it can be discussed/solved timely. Add Discussion

How to Add New Discussion in Study Group ? Step By Step Guide Click Here.

CS201 Assignment No 01 Fall 2019 Solution & Discussion Due Date: 14-11-2019

Programming is a nice tool which can be used to make our life easier. With the help of programming we can do many things auto generated and efficiency. As a programmer first task of this semester is given to you is develop a console-based application for school teachers. This application will auto generate questions for Grades 1, 2, 3, 4 and 5. Using this application teacher will be able to give different paper to each student.

 

Assignment Statement:

Write a menu-based program in C++ that will take input from user(teacher) and fulfill following requirements.

 

·        There should be a menu that allow to select grade of class.

·        Created questions should be mixed type (addition and subtraction).

·        User will give number of questions that will be generated for a paper.

·        Ratio of addition and subtraction questions is not fixed. It will random, a paper can have more questions of one type than other. See sample output screenshot.

·        Number of minimum and maximum digits in paper of grade 1 will be two.

·        Number of minimum and maximum digits in paper of grade 2 will be three.

·        Number of minimum and maximum digits in paper of grade 3 will be four.

·        Number of minimum and maximum digits in paper of grade 4 will be five.

·        Number of minimum and maximum digits in paper of grade 5 will be six.

·        Screen shot of required application is given below as simple output.

·        Most critical requirement is, the operand (number) on left side of subtraction sign must be larger than the number on right side of sign (operator). This requirement is highlighted in sample screenshot too.

·        In case of addition operation, the operand (number) on left side of addition sign can be larger or smaller from the number on right side of sign (operator).  

 

Solution instructions:

·        Variables, loops, if-else, rand() function with % operator, functions (one which return a value and one which do not return a value) will help you to solve the problem.

·        Use rand() function to generate a random number. You can control the range of number with the help of modulus (%) operator.

·        To use rand() function you must include “stdlib.h” header file.

·        To control the range of random number rand() % N can help, if value of N will be 100 then  range of randomly generated number will be 0 to 99.

·        If you want to control the range of random number between 10 to 19 then following formula will help.

o       [10 + rand() % (19 – 10 + 1)]

 

 

 

 

 

 

 

 

 

 

Sample output:

In case of subtraction number on left side of operator must be larger than number on right side

 

In case of addition number on left side of operator can be smaller than number on right side

 

 

 

+ How to Follow the New Added Discussions at Your Mail Address?

+ How to Join Subject Study Groups & Get Helping Material?

+ How to become Top Reputation, Angels, Intellectual, Featured Members & Moderators?

+ VU Students Reserves The Right to Delete Your Profile, If?


See Your Saved Posts Timeline

Views: 4513

.

+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

+ Click Here to Search (Looking For something at vustudents.ning.com?)

+ Click Here To Join (Our facebook study Group)

Attachments:

Replies to This Discussion

Please Discuss here about this assignment.Thanks

Our main purpose here discussion not just Solution

Discussed & be touched with this discussion. After discussion a perfect solution will come in a result at the end.

 

 

P.S:    Please always try to add the discussion in proper format title like “CS101 Assignment / GDB No 01 Solution & Discussion Due Date: ___________”

Then copy Questions from assignment file and paste in Discussion.

 

http://bit.ly/vucodes (For Assignments, GDBs & Online Quizzes Solution)

http://bit.ly/papersvu (For Past Papers, Solved MCQs, Short Notes & More)

Click Here to Search (Looking For something at vustudents.ning.com?)

Click Here to Join (Our facebook study Group)

CS201 Assignment 1 Solution Fall 2019 | Virtual University |

MUHAMMAD USMAN

Email, cell no, facebook personal links, links sharing for promotion any kind of site & youtube direct link sharing is not allowed at the site.

 

Although If you want to share the youtube video, then paste the embed codes here of the youtube video. Otherwise your comment / reply will be deleted. As well as your account will be deleted from the site. Thanks for understanding.

CS201 Solution Fall 2019

CS201 Assignment 1 Solution

see the attached file

CS201 Assignment 1 Solution

Solution

#include <iostream>

#include <stdlib.h>

 

using namespace std;

 

void  menu(){

                cout"1 : First Grade"endl;

    cout"2 : Second Grade"endl;

    cout"3 : Third Grade"endl;

    cout"4 : Fourth Grade"endl;

    cout"5 : Fifth Grade"endl;

                coutendl;

                               

}

 

int minRange(int number){

 

if(number == 1){

                return 10;

}else if(number == 2){

                return 100;

}else if(number == 3){

                return 1000;

}else if(number == 4){

                return 10000;

}else if(number == 5){

                return 100000;

}

               

}

 

int maxRange(int number){

 

if(number == 1){

                return 99;

}else if(number == 2){

                return 999;

}else if(number == 3){

                return 9999;

}else if(number == 4){

                return 99999;

}else if(number == 5){

                return 999999;

}

               

}

 

char randomOperator(){

                return "+-"[rand() % 2];

}

 

int main(){

               

               

               

                menu();

                int ch,q,min,max;

               

                cout"Please select grade, user numbers 1 to 5:  ";

                cin>>ch;

                if(ch == 1){

                                min = minRange(1);

                                max = maxRange(1);

                }else if(ch == 2){

                                min = minRange(2);

                                max = maxRange(2);

                }else if(ch == 3){

                                min = minRange(3);

                                max = maxRange(3);

                }else if(ch == 4){

                                min = minRange(4);

                                max = maxRange(4);

                }else if(ch == 5){

                                min = minRange(5);

                                max = maxRange(5);

                }

               

                cout"Enter number of questions you want to generate:  ";

                cin>>q;

                coutendl;

                int serial = 1;

                int lineBreak = 1;

                for(int i = 0 ; i < q; i++){

                                if(serial < 10){

                                coutserial".   ";

                                }else if(serial < 100){

                                                coutserial".  ";

                                }

                                int firstNum =   rand() % (max - min + 1) + min;

                                int secNum  =   rand() % (max - min + 1) + min;

                                char opr = randomOperator();

                               

                                if(opr == '+'){

                                                cout"("firstNumoprsecNum") = ________ \t";

                                                if(ch != 5){

                                                                cout"\t";

                                                } 

                                }else if(opr == '-'){

                                                if(firstNum > secNum){

                                                                cout"("firstNumoprsecNum") = ________ \t";

                                                                if(ch != 5){

                                                                cout"\t";

                                                }   

                                                }else{

                                                                cout"("secNumoprfirstNum") = ________ \t"; 

                                                if(ch != 5){

                                                                cout"\t";

                                                } 

                                                }

                                }

                                serial++;

                }

               

}

I developed this program like this is it all right?

#include <iostream>

#include <iomanip>

using namespace std;

int main()

{

    srand(time(NULL));

cout "First Grade\n";

cout "Second Grade\n";

cout "Third Grade\n";

cout "Forth Grade\n";

cout "Fifth Grade\n";

int a;

cout "Select a grade Of Class 1 to 5\n";

cout "Enter number of questions you want to generate\n";

 cin >> a;

 int b;

 cin >> b;

 int lower=1000; 

 int upper=9000;

  char operator1;

 int operatorDefine;

const char separator    = ' ';

    const int nameWidth     = 3;

    const int numWidth      = 3;

int counter = 0;

 

if(a==1){

   for(int c = 1; c<=b; c++){

  int operatorDefine = rand() % 2 + 1;

if (operatorDefine == 1){

         operator1 = '+';

    }else if(operatorDefine == 2){

         operator1 = '-';

    }

    

  counter++;

    

if(operator1 == '-'){

   

   

    int num1 = (rand() % 

(99 - 10))+ 10; 

int num2 = (rand() % (++num1 - 10)+ 10); 

cout c". ";

cout"(";

cout("%d", num1); 

cout("%d",operator1);

cout("%d", num2);

cout")";

cout(" = ------   ");

}

else if(operator1 == '+'){

    int num1 = (rand() % 

(99 - 10)) + 10; 

  int num2 = (rand() % 

(99 - 10)) + 10;

cout c". ";

cout"(";

cout("%d", num1); 

cout("%d",operator1);

cout("%d", num2);

cout")";

cout(" = ------   ");

 

}

if (counter % 3 == 0) cout "\n" ;

 } 

}

else if(a == 2){

    for(int c = 1; c<=b; c++){

  int operatorDefine = rand() % 2 + 1;

if (operatorDefine == 1){

         operator1 = '+';

    }else if(operatorDefine == 2){

         operator1 = '-';

    }

    

   counter++;

    

if(operator1 == '-'){

    

    int num3 = (rand() % 

(999 - 100)) + 100; 

int num4 = (rand() % 

(++num3 - 100)) + 100; 

cout c". ";

cout"(";

cout("%d", num3); 

cout("%d",operator1);

cout("%d", num4);

cout")";

cout(" = ------   ");

}

else if(operator1 == '+'){

    int num3 = (rand() % 

(999 - 100 + 1)) + 100; 

  int num4 = (rand() % 

(999 - 100 + 1)) + 100; 

cout c". ";

cout"(";

cout("%d", num3); 

cout("%d",operator1);

cout("%d", num4);

cout")";

cout(" = ------   ");

 

}

if (counter % 3 == 0) cout "\n" ;

 } 

}else if(a==3){

    for(int c = 1; c<=b; c++){

  int operatorDefine = rand() % 2 + 1;

if (operatorDefine == 1){

         operator1 = '+';

    }else if(operatorDefine == 2){

         operator1 = '-';

    }

     counter++;

  

    

if(operator1 == '-'){

    

    int num = (rand() % 

(upper - lower + 1)) + lower; 

int num2 = (rand() % 

(++num - 1000)) + lower; 

cout c". ";

cout"(";

cout("%d", num); 

cout("%d",operator1);

cout("%d", num2);

cout")";

cout(" = ------   ");

}

else if(operator1 == '+'){

    int num = (rand() % 

(upper - lower + 1)) + lower; 

  int num2 = (rand() % 

(upper - lower + 1)) + lower; 

cout c". ";

cout"(";

cout("%d", num); 

cout("%d",operator1);

cout("%d", num2);

cout")";

cout(" = ------   ");

 

}

if (counter % 3 == 0) cout "\n" ;

 }

}else if(a==4){

    for(int c = 1; c<=b; c++){

  int operatorDefine = rand() % 2 + 1;

if (operatorDefine == 1){

         operator1 = '+';

    }else if(operatorDefine == 2){

         operator1 = '-';

    }

     counter++;

  

    

if(operator1 == '-'){

    

    int num = (rand() % 

(10000 - 90000 + 1)) + 10000; 

int num2 = (rand() % 

(++num - 10000)) + 10000; 

cout c". ";

cout"(";

cout("%d", num); 

cout("%d",operator1);

cout("%d", num2);

cout")";

cout(" = ------   ");

}

else if(operator1 == '+'){

    int num = (rand() % 

(10000 - 90000 + 1)) + 10000; 

  int num2 = (rand() % 

(10000 - 90000 + 1)) + 10000; 

cout c". ";

cout"(";

cout("%d", num); 

cout("%d",operator1);

cout("%d", num2);

cout")";

cout(" = ------   ");

 

}

if (counter % 3 == 0) cout "\n" ;

 }

}else if(a=5){

    for(int c = 1; c<=b; c++){

  int operatorDefine = rand() % 2 + 1;

if (operatorDefine == 1){

         operator1 = '+';

    }else if(operatorDefine == 2){

         operator1 = '-';

    }

     counter++;

  

    

if(operator1 == '-'){

    

    int num = (rand() % 

(900000 - 100000 + 1)) + 100000; 

int num2 = (rand() % 

(++num - 100000)) + 100000; 

cout c". ";

cout"(";

cout("%d", num); 

cout("%d",operator1);

cout("%d", num2);

cout")";

cout(" = ------   ");

}

else if(operator1 == '+'){

    int num = (rand() % 

(900000 - 100000 + 1)) + 100000; 

  int num2 = (rand() % 

(900000 - 100000 + 1)) + 100000; 

cout c". ";

cout"(";

cout("%d", num); 

cout("%d",operator1);

cout("%d", num2);

cout")";

cout(" = ------   ");

 

}

if (counter % 3 == 0) cout "\n" ;

 }

}

     

 }

 

cs201 Assignment solution

link

cs201 Assignment solution

CS201 Introduction to Programming Assignment 1 Solution Fall 2019


 

#include <iostream>
#include <stdlib.h>
using namespace std;
void questionPaper(int grade, int questions){

for(int i=1;i<=questions;i++)
{
int big,small;
int digits1,digits2;

if(grade == 1)
{

digits1 = (10+rand()%(99-10+1));
digits2 = (10+rand()%(99-10+1));

if(digits1 < digits2)
{
small = digits1;
big = digits2;
}
else
{
big = digits1;
small = digits2;
}


if(digits1 == big)
{
cout i "("big "-" small ") = _________" endl;
}
else if(digits1 == small)
{
cout i "("small "+" big ") = _________" endl;
}

}//grade 1

else if(grade == 2)
{

digits1 = (100+rand()%(999-100+1));
digits2 = (100+rand()%(999-100+1));

if(digits1 < digits2)
{
small = digits1;
big = digits2;
}
else
{
big = digits1;
small = digits2;
}


if(digits1 == big)
{
cout i "("big "-" small ") = _________" endl;
}
else if(digits1 == small)
{
cout i "("small "+" big ") = _________" endl;
}

}//grade 2

else if(grade == 3)
{

digits1 = (1000+rand()%(9999-1000+1));
digits2 = (1000+rand()%(9999-1000+1));

if(digits1 < digits2)
{
small = digits1;
big = digits2;
}
else
{
big = digits1;
small = digits2;
}


if(digits1 == big)
{
cout i ". ("big "-" small ") = _________" endl;
}
else if(digits1 == small)
{
cout i ". ("small "+" big ") = _________" endl;
}

}//grade 3

else if(grade == 4)
{

digits1 = (10000+rand()%(99999-10000+1));
digits2 = (10000+rand()%(99999-10000+1));

if(digits1 < digits2)
{
small = digits1;
big = digits2;
}
else
{
big = digits1;
small = digits2;
}


if(digits1 == big)
{
cout i ". ("big "-" small ") = _________" endl;
}
else if(digits1 == small)
{
cout i ". ("small "+" big ") = _________" endl;
}

}//grade 4

else if(grade == 5)
{

digits1 = (100000+rand()%(999999-100000+1));
digits2 = (100000+rand()%(999999-100000+1));

if(digits1 < digits2)
{
small = digits1;
big = digits2;
}
else
{
big = digits1;
small = digits2;
}


if(digits1 == big)
{
cout i ". ("big "-" small ") = _________" endl;
}
else if(digits1 == small)
{
cout i ". ("small "+" big ") = _________" endl;
}

}//grade 5
}

}

main() {
int grade,question;

cout "1 : First Grade" endl;
cout "2 : Second Grade" endl;
cout "3 : Third Grade" endl;
cout "4 : Fourth Grade" endl;
cout "5 : Fifth Grade" endl;

cout "Please Select grade, user number 1 to 5 :";
cin >> grade;

cout "Enter number of questions you want to generate :";
cin >> question;


questionPaper(grade,question);

}

CS201-Assignment-1-Solution-Fall-2019-VU-Ning

link 

CS201-Assignment-1-Solution-Fall-2019-VU-Ning

CS201: 1st assignment Solution

Note: Please make necessary changes according to your study scheme before submitting.

link 

cs201 (2)

which app is used to open link??

RSS

© 2019   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service

.