Encrypting your link and protect the link from viruses, malware, thief, etc! Made your link safe to visit.

The number of lines that can be printed on a paper depends on the paper size

 

Answer:


Program Plan Intro

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 Answer

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 Singlespaced,d or D Doublespaced:";

  cin>>line_Space;

  space = line_Space[0];

  //calculation

  final_Length = int length(topMargin+bottomMargin);

  final_Width = width - leftMargin+rightMargin;

  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 space==DoubleUpper||space==DoubleLower

  {

   point_Size += point_Size;

   total_Lines = int pointsLength/pointSize;

   total_Characters = int pointsWidth/pointSize;

   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 space==SingleUpper||space==SingleLower{

   total_Lines = int pointsLength/pointSize;

   total_Characters = int pointsWidth/pointSize;

   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

  

Sample Output

C++ Programming: From Problem Analysis to Program Design, Chapter 4, Problem 13PE

ST

Search This Blog

Labels

Report Abuse

Question: A 250-V, 4-pole, wave-wound d.c. series motor has 782 conductors on itsarmature. It has armature and series field resistance of 0.75 ohm. The motor takesa current of 40 A. Estimate its speed and gross torque developed if it has a flux per pole of 25 mWb Answer: Step 1 Mechanical Engineering homework question answer, step 1, image 1 Mechanical Engineering homework question answer, step 1, image 2 Step 2 Mechanical Engineering homework question answer, step 2, image 1 Step 3 Mechanical Engineering homework question answer, step 3, image 1

Question: A 250-V, 4-pole, wave-wound d.c. series motor has 782 conductors on itsarmature. It has armature and series field resistance of 0.75 ohm. The motor takesa current of 40 A. Estimate its speed and gross torque developed if it has a flux per pole of 25 mWb Answer: Step 1 Step 2 Step 3

QUESTION 6 (a) The bar shown in Figure Q2(a) is subjected to tensile load of 150 Kn. If the stress in the middle portions is limited to 160 N/mm², determine the diameter of the middle portion. Find also the length of the middle portion if the total elongation of the bar is to be 0.25 mm. E E = 2.0 + 105N/mm². (12 marks) 150 KN 10 cm DIA 10 cm DIA 150 KN 45 cm Figure Q6(a) (b) A brass bar, having cross-section area of 900 mm², is subjected to axial forces as shown in Figure Q2(b), in which AB = 0.6 m, BC = 0.8 m, and CD = 1.0 m. Find the total elongation of the bar. E = 1.0 + 105N/mm2 . (8 marks) Page 4 of 5 B D 40 KN 70 KN 20 KN 10 KN Figure Q6(b) (TOTAL = 20 MARKS)

  Question: Show transcribed image text Answer:

Contributors