The number of lines that can be printed on a paper depends on the paper size
Answer:
Implementation of a program that takes various inputs from the user to calculate the number of characters in a line and the number of lines that can be printed on a paper.
Program Plan:
Write a C++ program with a main function and the required set of statements to accomplish the following:
- Prompts the user to enter the various inputs and get the input from the user like length, width of the paper.
- Get the input like top, bottom, left, right margins and point size of the line.
- Using if-else statement check if the user has entered single spaced or double- spaced line.
- Display number of characters in a line and the number of lines that can be printed on a paper.
Program Description:
- The following C++ program prompts the user to enter the various inputs and get the input from the user like length, width of the paper. Get the input like top, bottom, left, right margins and point size of the line. Using if-else statement check if the user has entered single spaced or double- spaced line. Display number of characters in a line and the number of lines that can be printed on a paper.
Explanation of Solution
Program:
//include the required header file
#include <iostream>
#include <cmath>
using namespace std;
//definition of the main function
int main
{//declare the required variables
int One_Inch = 72;
char Double_Lower = ‘d';
char Double_Upper = ‘D';
char Single_Lower = ‘s';
char Single_Upper = ‘S';
char space = 0;
double length = 0;
double width = 0;
double left_Margin = 0;
double right_Margin = 0;
double top_Margin = 0;
double bottom_Margin = 0;
double point_Size = 0;
int total_Characters = 0;
int total_Lines = 0;
int final_Length = 0;
double final_Width = 0;
int points_Length = 0;
double points_Width = 0;
string line_Space;
//prompt the user the messages and get the desired input from the user
cout<<"Enter the length of the paper:";
cin>>length;
cout<<"Enter the width of the paper:";
cin>>width;
cout<<"Enter the left margin of the paper:";
cin>>left_Margin;
cout<<"Enter the right margin of the paper:";
cin>>right_Margin;
cout<<"Enter the top margin of the paper:";
cin>>top_Margin;
cout<<"Enter the bottom margin of the paper:";
cin>>bottom_Margin;
cout<<"Enter the point size of the paper:";
cin>>point_Size;
cout<<"Enterline spacing,s or S ,d or D :";
cin>>line_Space;
space = line_Space[0];
//calculation
final_Length = );
final_Width = width - ;
points_Length = final_Length * One_Inch;
points_Width = final_Width * One_Inch;
//check the condition and if the condition is true then display the statements written in if body.
if
{
point_Size += point_Size;
total_Lines = ;
total_Characters = ;
cout<<"The number of lines that can be printed : “<< total_Lines<<endl;
cout<<"The number of characters that can be printed in a line: “<<total_Characters<<endl;
}
//otherwise display the statements written in the else body.
else if {
total_Lines = ;
total_Characters = ;
cout<<"The number of lines that can be printed : “<<total_Lines<<endl;
cout<<"The number of characters that can be printed in a line: “<< total_Characters<<endl;
}
}//end of the main function