1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
____ [38]
3 years ago
13

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] =
Engineering
1 answer:
ddd [48]3 years ago
3 0

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

You might be interested in
A highway reconstruction project is being undertaken to reduce crash rates. The reconstruction involves a major realignment of t
CaHeK987 [17]

Answer:

The provided length of the vertical curve is satisfactory for the reconstruction design speed of 60 mi/h

Explanation:

The explanation is shown on the first uploaded image

8 0
3 years ago
Say you have a random, unordered list containing 4096 four-digit numbers. Describe the most efficient way to: sort the list and
Debora [2.8K]

Answer:

Answer explained below

Explanation:

It is given that numbers are four-digit so maximum value of a number in this list could be 9999.

So we need to sort a list of integers, where each integer lies between [0,9999].

For these given constraints we can use counting sort which will run in linear time i.e. O(n).

--------------------------------------------------------------------------------

Psuedo Code:

countSort(int numList[]) {

int count[10000];

count[i] = 0; for all i;

for(int num in numList){

count[num]+= 1;

}

return count;

}

--------------------------------------------------------------------------------

Searching in this count array will be just O(1).

E.g. Lets say we want to search if 3 was present in the original list.

Case 1: it was present in the original list:

Then the count[3] would have been incremented by our sorting algorithm. so in case element exists then count value of that element will be greater than 0.

Case 2: it was not present:

In this case count[3] will remain at 0. so in case element does not exist then count of that element will be 0.

So to search for an element, say x, we just need to check if count[x]>0.

So search is O(1).

Run times:

Sorting: O(n)

Search: O(1)

6 0
3 years ago
How do I do this?<br> Blueprints, complete the missing view.
Ymorist [56]

Explanation:

Look at the drawings and decide which view is missing. Front? Side? Top? Then draw it

7 0
3 years ago
An excavation is at risk for cave-in and water accumulation because of the excess soil that has accumulated. What type of excava
s344n2d4d5 [400]

Answer:

Among the different types of excavation protection system, as a way of preventing accidents against cave-ins, the sloping involves cutting back the trench wall at an angle inclined away from the excavation. Shoring requires installing aluminum hydraulic or other types of supports to prevent soil movement and cave-ins. Shielding protects workers by using trench boxes or other types of supports to prevent soil cave-ins (OSHA). In addition, the regulations do not allow employees to work on excavations where there is an accumulation of water. If this occurs, water on the site must be constantly removed by suitable equipment preventing water from accumulating. The entry of surface water into the excavations must also be prevented by means of diversion ditches, dam, or other suitable means.  

Explanation:

3 0
3 years ago
A rod that was originally 100-cm-long experiences a strain of 82%. What is the new length of the rod?
lisabon 2012 [21]

Answer:

The new length of the rod is 182 cm.

Explanation:

Given that a rod that was originally 100-cm-long experiences a strain of 82%, to determine what is the new length of the rod, the following calculation must be performed:

100 x 1.82 = X

182 = X

 

Therefore, the new length of the rod is 182 cm.

7 0
3 years ago
Other questions:
  • How fast is a 2012 nissan sentra<br>speed and acceleration ​
    15·1 answer
  • What happens to a commercial airline at cruising altitude if the pilot does not touch the throttles?
    12·1 answer
  • What is the linear distance traveled in one revolution of a 36-inch wheel
    6·1 answer
  • Which are the most common location for a collision between a bike and a car?
    8·1 answer
  • What are the characteristic features of stress corrosion cracks?
    15·1 answer
  • Sarah and Raj take/takes me to a baseball game every year.
    11·1 answer
  • How many kg moles of Sodium Sulphate will contain 10 kg of<br> Sodium?
    10·2 answers
  • Explain crystallographic defects.
    11·1 answer
  • a storage tank contains liquid with a density of 0.0361 lbs per cubic inch. the height of liquid in the tank is 168 feet. what i
    8·1 answer
  • Write down the three formula to find the three types of slope of curve Q with respect to L.
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!