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

Please use \"cout and cin\" or \"scanf and printf\" Thank you Question 1: Write

ID: 3694335 • Letter: P

Question

Please use "cout and cin" or "scanf and printf"
Thank you

Question 1:  Write a complete C++ program that reads a four digit integer into a variable x ; then it produces another four digit integer y by swapping the least and most significant digits of x.

e.g. if x = 7894 then   y=4897
         if  x=2884 then y=4882

Question 2:  An Wireless internet service provider has three different subscription package for customers
Package 1: $9.95 per month for 10 hours limited access and $2.00 for additional per hour.
Package 2: $14.95 per month for 20 hours limited access and $1.50 for additional per hour.
Package 3: $19.95 per mount for unlimited access.
 
Write a program that calculates a customer’s monthly bill.
Program asks customer name, which package customer has, and how many hours were used.
Program prints the final bill, which has all information in the bill.

Explanation / Answer

Program 1:

#include <iostream>

using namespace std;

int main()
{
    int input,n,output,no[4],i;
   cout << "enter four digit no: ";
   cin>>input;
   n=input;
do
{
   no[i]= n % 10;
   i++;
    n /= 10;
} while (n > 0);

for(i=0;i<4;i++)
{
    cout<<no[i];
}
cout<<endl;
   return 0;
}

Program 2:

#include <iostream>

using namespace std;

int main()
{
    int package,hrs;
    double total;
    char name[100];
    cout<<"Enter your name: ";
    cin>>name;
    cout<<"Enter your package: ";
    cin>>package;
    cout<<"Enter no of hours used: ";
    cin>>hrs;
    switch(package)
    {
        case 1: total+=9.95;
                if(hrs>10)
                total+=(hrs-10)*2;
                break;
         case 2: total+=14.95;
                if(hrs>20)
                total+=(hrs-20)*1.50;
                break;
         case 3: total+=19.95;
                break;      
    }
    cout<<"****Your bill for this month is printed below***";
    cout<<"Customer's Name: "<<name<<endl;
    cout<<"Package: "<<package<<endl;
    cout<<"Total hrs used: "<<hrs<<endl;
    cout<<"Bill Amount: "<<total<<endl;

   return 0;
}