NPTEL Programming in Modern C++ Programming Assignment week-5 July-2023 Swayam

 

W5_Programming_Qs.1

Due on 2023-08-31, 23:59 IST
Consider the following program. Fill in the blanks as per the instructions given below:
   • Complete the inheritance statement at LINE-1,
   • Complete the return statement at LINE-2 and LINE-3 to calculate the volume and surface
     area of a cube,
such that it will satisfy the given test cases. 
Your last recorded submission was on 2023-08-22, 14:30 IST
Select the Language for this assignment. 
#include <iostream>
using namespace std;
class Volume {
    public:
        double getValue(int a) { return (a * a * a); }
};
class SurfaceArea {
    public:
        double getValue(int a) { return 6 * a * a; }
};
class Cube : public Volume, public SurfaceArea { //LINE-1
    int _a;
 
    public:
        Cube(int a) : _a(a) { }
 
        double getVolume() { return Volume::getValue(_a); } //LINE-2
 
        double getSurfaceArea() { return SurfaceArea::getValue(_a) ; } //LINE-3
};
int main() {
    int a;
    cin >> a;
    Cube c(a);
    cout << c.getVolume() << ", " << c.getSurfaceArea();
    return 0;
}
You may submit any number of times before the due date. The final submission will be considered for grading.
This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program , your assignment will not be graded and you will not see your score after the deadline.
   


 
 
Public Test CasesInputExpected OutputActual OutputStatus
Test Case 1
4
64, 96
64, 96
Passed
Test Case 2
3
27, 54
27, 54
Passed


W5_Programming_Qs.2

Due on 2023-08-31, 23:59 IST
Consider the following program. Fill in the blanks as per the instructions given below.
   • at LINE-1 with appropriate keyword,
   • at LINE-2 and LINE-3 with appropriate constructor statements
such that it will satisfy the given test cases.
Your last recorded submission was on 2023-08-22, 14:31 IST
Select the Language for this assignment. 
#include <iostream>
using namespace std;
class Vehicle{
    string vehicleName;
    int noOfWheels;
    protected:
        Vehicle(string s, int w) : vehicleName(s), noOfWheels(w) { }
    public:
        friend void vehicleDetails(const Vehicle&); //LINE-1
};
class Twowheeler : public Vehicle{
    public:
        Twowheeler(string n) : Vehicle(n,2) { } //LINE-2
};
class Fourwheeler : public Vehicle{
    public:
        Fourwheeler(string n) : Vehicle(n,4) { } //Line-3
};
void vehicleDetails(const Vehicle &v){
    cout << v.vehicleName << ": ";
    if(v.noOfWheels == 2)
        cout << "Two Wheeler";
    else if(v.noOfWheels == 4)
        cout << "Four Wheeler";
}
int main(){
    string s;
    int n;
    Vehicle *v;
    cin >> s >> n;
    if(n==2)
        v = new Twowheeler(s);
    else if(n==4)
        v = new Fourwheeler(s);
    vehicleDetails(*v);
    return 0;
}
You may submit any number of times before the due date. The final submission will be considered for grading.
This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program , your assignment will not be graded and you will not see your score after the deadline.
   


 
 
Public Test CasesInputExpected OutputActual OutputStatus
Test Case 1
Bus 4
Bus: Four Wheeler
Bus: Four Wheeler
Passed
Test Case 2
Bike 2
Bike: Two Wheeler
Bike: Two Wheeler
Passed



W5_Programming_Qs.3

Due on 2023-08-31, 23:59 IST
Consider the following program. Fill in the blanks as per the instructions given below.
    • at LINE-1 with appropriate inheritance statement,
    • at LINE-2 with appropriate constructor statement
such that it will satisfy the given test cases.
Your last recorded submission was on 2023-08-22, 14:26 IST
Select the Language for this assignment. 
#include<iostream>
using namespace std;
class B1{
    protected:
        int b1;
    public:
        B1(int b) : b1(b){}
};
class B2{
    protected:
        int b2;
    public:
        B2(int b) : b2(b){}
};
class D : public B1, public B2 { //LINE-1
 
    int d;
 
public:
 
    D(int x) : d(x), B1(x+5), B2(x+10) {} //LINE-2
void show(){
        cout << d << ", " << b1 << ", " << b2;
    }
};
int main(){
    int x;
    cin >> x;
    D t1(x);
    t1.show();
    return 0;
}
You may submit any number of times before the due date. The final submission will be considered for grading.
This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program , your assignment will not be graded and you will not see your score after the deadline.
   


 
 
Public Test CasesInputExpected OutputActual OutputStatus
Test Case 1
1
1, 6, 11
1, 6, 11
Passed
Test Case 2
5
5, 10, 15
5, 10, 15
Passed





Private Test cases used for EvaluationStatus
Test Case 1
Passed



No comments

File Uploading in PHP

  File Uploading in PHP PHP allow you to upload any type of a file i.e. image, binary or text files.etc..,PHP has one in built global variab...