Write a C++ program to display yearly calendar. You need to use the array defined below in your program. // the first number is the month and second number is the last day of the month. into yearly[12][2] =

Answers

Answer 1
Answer:

Answer:

//Annual calendar

#include <iostream>

#include <string>

#include <iomanip>

void month(int numDays, int day)

{

int i;

string weekDays[] = {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"};

// Header print

      cout << "\n----------------------\n";

      for(i=0; i<7; i++)

{

cout << left << setw(1) << weekDays[i];

cout << left << setw(1) << "|";

}

cout << left << setw(1) << "|";

      cout << "\n----------------------\n";

      int firstDay = day-1;

      //Space print

      for(int i=1; i< firstDay; i++)

          cout << left << setw(1) << "|" << setw(2) << " ";

      int cellCnt = 0;

      // Iteration of days

      for(int i=1; i<=numDays; i++)

      {

          //Output days

          cout << left << setw(1) << "|" << setw(2) << i;

          cellCnt += 1;

          // New line

          if ((i + firstDay-1) % 7 == 0)

          {

              cout << left << setw(1) << "|";

              cout << "\n----------------------\n";

              cellCnt = 0;

          }

      }

      // Empty cell print

      if (cellCnt != 0)

      {

          // For printing spaces

          for(int i=1; i<7-cellCnt+2; i++)

              cout << left << setw(1) << "|" << setw(2) << " ";

          cout << "\n----------------------\n";

      }

}

int main()

{

int i, day=1;

int yearly[12][2] = {{1,31},{2,28},{3,31},{4,30},{5,31},{6,30},{7,31},{8,31},{9,30},{10,31},{11,30},{12,31}};

string months[] = {"January",

"February",

"March",

"April",

"May",

"June",

"July",

"August",

"September",

"October",

"November",

"December"};

for(i=0; i<12; i++)

{

//Monthly printing

cout << "\n Month: " << months[i] << "\n";

month(yearly[i][1], day);

if(day==7)

{

day = 1;

}

else

{

day = day + 1;

}

cout << "\n";

}

return 0;

}

//end


Related Questions

What are the important factors needed to be considered while selecting a brake or clutch?
write an interface downloadable that has a method "geturl" that returns the url of a downloadable object
Which of the following was an effect of world war 2 on agricultural industry
) A flow is divided into two branches, with the pipe diameter and length the same for each branch. A 1/4-open gate valve is installed in line A, and a 1/3-closed ball valve is installed in line B. The head loss due to friction in each branch is negligible compared with the head loss across the valves. Find the ratio of the velocity in line A to that in line B (include elbow losses for threaded pipe fittings).
Assuming that the following three variables have already been declared, which variable will store a Boolean value after these statements are executed? choice = true; again = "false"; result = 0; a. choice b. again c. result d. none of these are Boolean variables

Indicate whether the following statements are true or false for an isothermal process: (A) Q=T(∆S). (B) ∆U=0.(C) The entropy change of the system is always zero. (D) The total entropy change of the system and the surroundings is always zero. (E) The entropy change of the surroundings is negative. (F) Q=W.

Answers

Answer:

A=False

B=False

C=False

D=False

E=False

F=False

Explanation:

A. In an isothermal process, only the reversibly heat transfer is 0, Q_(rev)=T (\Delta S)

B. Consider the phase change of boiling water. Here, the temperature remains constant but the internal energy of the system increases.

C. This is not true even in reversible process, as can be inferred from the equation in part A.

D. This is only true in reversible processes, but not in all isothermal processes.

E. Consider the phase change of freezing water. Here, the surroundings are increasing their entropy, as they are taking in heat from the system.

F. This is not true if (\Delta U)\neq 0, like in answer B. One case where this is true is in the reversible isothermal expansion (or compression) of an ideal gas.

Steam enters a turbine from a 2 inch diameter pipe, at 600 psia, 930 F, with a velocity of 620 ft/s. It leaves the turbine at 12 psia with a quality of 1.0, through an outlet duct 1 ft in diameter. Calculate the turbine power output

Answers

Answer:

\dot W_(out) = 3374.289\,(BTU)/(s)

Explanation:

The model for the turbine is given by the First Law of Thermodynamics:

- \dot W_(out) + \dot m \cdot (h_(in) - h_(out)) = 0

The turbine power output is:

\dot W_(out) = \dot m\cdot (h_(in)-h_(out))

The volumetric flow is:

\dot V = (\pi)/(4) \cdot \left( (2)/(12)\,ft \right)^(2)\cdot (620\,(ft)/(s) )

\dot V \approx 13.526\,(ft^(3))/(s)

The specific volume of steam at inlet is:

State 1 (Superheated Steam)

\nu = 1.33490\,(ft^(3))/(lbm)

The mass flow is:

\dot m = (\dot V)/(\nu)

\dot m = (13.526\,(ft^(3))/(s) )/(1.33490\,(ft^(3))/(lbm) )

\dot m = 10.133\,(lbm)/(s)

Specific enthalpies at inlet and outlet are, respectively:

State 1 (Superheated Steam)

h = 1479.74\,(BTU)/(lbm)

State 2 (Saturated Vapor)

h = 1146.1\,(BTU)/(lbm)

The turbine power output is:

\dot W_(out) = (10.133\,(lbm)/(s) )\cdot (1479.1\,(BTU)/(lbm)-1146.1\,(BTU)/(lbm))

\dot W_(out) = 3374.289\,(BTU)/(s)

A household refrigerator that has a power input of 450 W and a COP of 1.5 is to cool 5 large watermelons, 10 kg each, to 8 C. If the watermelons are initially at 28 C, determine how long it will take for the refrigerator to cool them.

Answers

Answer:

\Delta t = 5866.667\,s\,(97.778\,m)

Explanation:

The specific heat for watermelon above freezing point is 3.96\,(kJ)/(kg\cdot K). The heat liberated by the watermelon to cool down to 8°C is:

Q_(cooling) = (5)\cdot (10\,kg)\cdot (3.96\,(kJ)/(kg\cdot K) )\cdot (20\,K)

Q_(cooling) = 3960\,kJ

The heat absorbed by the household refrigerator is:

\dot Q_(L) = COP\cdot \dot W_(e)

\dot Q_(L) = 1.5\cdot (0.45\,kW)

\dot Q_(L) = 0.675\,kW

Time needed to cool the watermelons is:

\Delta t = (Q_(cooling))/(\dot Q_(L))

\Delta t = (3960\,kJ)/(0.675\,kW)

\Delta t = 5866.667\,s\,(97.778\,m)

 

Peter the postman became bored one night and, to break the monotony of the night shift, he carried out the following experiment with a row of mailboxes in the post office. These mailboxes were numbered 1 through 150, and beginning with mailbox 2, he opened the doors of all the even-numbered mailboxes, leaving the others closed. Next, beginning with mailbox 3, he went to every third mail box, opening its door if it were closed, and closing it if it were open. Then he repeated this procedure with every fourth mailbox, then every fifth mailbox, and so on. When he finished, he was surprised at the distribution of closed mailboxes. Write a program to determine which mailboxes these were.

Answers

Answer:

//This Program is written in C++

// Comments are used for explanatory purpose

#include <iostream>

using namespace std;

enum mailbox{open, close};

int box[149];

void closeAllBoxes();

void OpenClose();

void printAll();

int main()

{

closeAllBoxes();

OpenClose();

printAll();

return 0;

}

void closeAllBoxes()

{

for (int i = 0; i < 150; i++) //Iterate through from 0 to 149 which literarily means 1 to 150

{

box[i] = close; //Close all boxes

}

}

void OpenClose()

{

for(int i = 2; i < 150; i++) {

for(int j = i; j < 150; j += i) {

if (box[j] == close) //Open box if box is closed

box[j] = open;

else

box[j] = close; // Close box if box is opened

}

}

// At the end of this test, all boxes would be closed

}

void printAll()

{

for (int x = 0; x < 150; x++) //use this to test

{

if (box[x] = 1)

{

cout << "Mailbox #" << x+1 << " is closed" << endl;

// Print all close boxes

}

}

}

Explanation:

List the RTL (Register Transfer Language) sequence of micro-operations needed to execute the instruction STORE X

from the MARIE instruction set architecture. Then write the corresponding signal sequence to perform these micro-operations and to reset the clock cycle counter.

You may refer to the provided "MARIE Architecture and Instruction Set" file in the Front Matter folder.

Answers

Answer:

So these are the RTL representation:

MAR<----X

MBR<-----AC

M[MAR]<------MBR

Control signal sequence are:

P3T0:MAR<----X

P2P3 P4T1:MBR<-----AC

P0P1 P3T2:M[MAR]<------MBR

Explanation:

STORE X instruction is used for storing the value of AC to the memory address pointed by X. This operation can be done by using the Register Transfers at System Level and this can be represented by using a notation called Register Transfer Language RTL. Let us see what are the register transfer operations happening at the system level.

1. First of all the address X has to be tranfered on to the Memory Address Register MAR.  

MAR<----X

2. Next we have to tranfer the contents of AC into the Memory Buffer Register MBR

MBR<-----AC

3. Store the MBR into memory where MAR points to.

M[MAR]<------MBR

So these are the RTL representation:

MAR<----X

MBR<-----AC

M[MAR]<------MBR

Control signal sequence are:

P3T0:MAR<----X

P2P3 P4T1:MBR<-----AC

P0P1 P3T2:M[MAR]<------MBR

Describe the difference between design guidelines or criteria and design performance. Explain the relationship between the use of guideline/criteria tools and performance tools during the design process

Answers

Answer:

PART A

Design guidelines are sets of procedures to be followed in order to enhance the designing of an object or other things.

Design Performance is the actual process of carrying out the design process of an object using the design guidelines or criteria.

PART B

(1) Design guidelines tools helps to enhance design Performance.

(2) Design guidelines tools helps the designing performance tools to be effective.

Explanation:Design guidelines are the various steps which has special tools used to guide the designer in order to enhance the designing performance tools and ensure that the design process is done devoid of errors.

Design Performance tools are tools which helps to enhance the actual design Activities.

Other Questions