Computer Programming Lab 3

Lab 03: Arithmetic Operators & Manipulator functions:
Exercise 1:
With the help of manipulator functions write the program that produces the following output

Source Code:
#include<iostream>
#include<iomanip>
using namespace std;
main()
{
            cout<<"\t"<<"\t"<<setfill('*')<<setw(35)<<fixed<<'*'<<endl;
    cout<<"\t"<<"\t"<<setw(1)<<"*"<<"     PROGRAMMING ASSIGNMENT 1"<<setw(1)<<"    *"<<endl;
    cout<<"\t"<<"\t"<<setw(1)<<"*"<<"     COMPUTER PROGRAMMING I"<<setw(1)<<"      *"<<endl;
    cout<<"\t"<<"\t"<<setw(1)<<"*"<<"     AUTHOR :: ??"<<setw(1)<<"                *"<<endl;
    cout<<"\t"<<"\t"<<setw(1)<<"*"<<"     DUE DATE: THURSDAY,JAN.24"<<setw(1)<<"   *"<<endl;
    cout<<"\t"<<"\t"<<setfill('*')<<setw(35)<<fixed<<'*'<<endl;
return 0;
}

Output:

Exercise 2:
To make a profit, a local store marks up the prices of its items by a certain percentage. Write a C++ program that reads the original price of the item sold, the percentage of the marked-up price, and the sales tax rate. The program then outputs the original price of the item, the percentage of the mark-up, the store’s selling price of the item, the sales tax rate, the sales tax, and the final price of the item. (The final price of the item is the selling price plus the sales tax.)
Source Code:
#include <iostream>
using namespace std;
  int main()
  {
   double orignal_price, Percentage_markedup_price, Sales_tax_rate, selling_price, Sales_tax, final_price,markupPercent;
   cout<<"Orignal Price Of The Item Sold= ";
   cin>>orignal_price;
  
   cout<<"Percentage marked-up price= ";
   cin>>markupPercent;
  
   cout<<"sales tax rate= " ;
   cin>>Sales_tax_rate;
  
   Percentage_markedup_price = orignal_price*(markupPercent/100);

  
   selling_price = orignal_price+ Percentage_markedup_price;
   Sales_tax= (Sales_tax_rate/100)*selling_price;
   final_price=   selling_price+ Sales_tax;
  
   cout<< "Percentage markedup price=" << Percentage_markedup_price  <<"\n" <<"sales tax=" <<Sales_tax <<"\n"<< "Selling Price of Item= " <<selling_price<<"\n"<<"Final price of item= "<<final_price;
  
   return 0;
  }
Output:
Exercise 3:
Write a program that prompts the user to enter the weight of a person in kilograms and outputs the equivalent weight in pounds. Output both the weights rounded to two decimal places. (Note that 1 kilogram ¼ 2.2pounds.) Format your output with two decimal places.
Source Code:
#include <iostream>
#include <iomanip>
using namespace std;
main ()
{
            double weightInkilogram, weightpounds;
            cout<< "enter Weight In Kilogram"<<endl;
            cin>>weightInkilogram;
             
    weightpounds=weightInkilogram*2.2;
           
            cout<<"pounds= "<<setprecision(2)<<fixed<<weightpounds;
            return 0;
}

Comments

Popular posts from this blog

Computer Programming Lab 5

Computer Programming lab 11

Computer Programming Lab 4