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
Nostrana [21]
3 years ago
8

Write a program that inputs an integer denoting a month (1 for January, 2 for February, ... , 12 for December), and outputs how

many days are in that month. Assume no leap years. For example, if the input is 2, the output is 28. If the input is 11, the output is 30.[ There are a variety of ways to do this...One approach is to use 12 separate if-then statements. Another approach uses just 3 if-then statements and the logical OR operator (which is ||). ]
Computers and Technology
1 answer:
Korolek [52]3 years ago
6 0

Answer:

// program in C++.

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

// variable

int inp_month;

cout<<"Enter month:";

// read month

cin>>inp_month;

// if month is february

if(inp_month==2)

cout<<"Number of days in month:28"<<endl;

// if month is 4 or 6 or 9 or 11

else if(inp_month==4||inp_month==6||inp_month==9||inp_month==11)

cout<<"Number of days in month:30"<<endl;

else

// for others month

cout<<"Number of days in month:31"<<endl;

return 0;

}

Explanation:

Read month from user and assign it to variable "inp_month".If month is 2 then  there is 28 days in the month.If input month is 4 or 6 or 9 or 11 then there is 30 days in the month.For other month there will be 31 days in month.We assume there is no leap year.

Output:

Enter month:4                                                                                                              

Number of days in month:30

You might be interested in
A digital system has been developed to measure temperatures in the range -10˚C to 100˚C. If the accuracy of the system is such t
8090 [49]

If you have 10 bits available then you can interpret any number in range [0,2^{10}-1]=[0,1023].

The system therefore could represent the actual temperature of 39°C.

Hope this helps.

7 0
2 years ago
Design a class that has an array of floating-point numbers. The constructor should accept an integer argument and dynamically al
attashe74 [19]

Answer:

See explaination for the code

Explanation:

Here is the code

class NumberArray

{

private:

float *aptr; // Pointer to the array

int arraySize; // Holds the array size

float max,min,avg;

public:

NumberArray(int); // Constructor

~NumberArray(); // Destructor

int size() const // Returns the array size

{ return arraySize; }

void storeNumber(float num,int ele);

float retrieveNumber(int ele);

float getHighest();

float getLowest();

float getAverage();

};

//*******************************************************

// Constructor for IntArray class. Sets the size of the *

// array and allocates memory for it. *

//*******************************************************

NumberArray::NumberArray(int s)

{

arraySize = s;

aptr = new float [s];

for (int count = 0; count < arraySize; count++)

*(aptr + count) = 0;

}

//******************************************************

// Destructor for IntArray class. *

//******************************************************

NumberArray::~NumberArray()

{

if (arraySize > 0)

delete [] aptr;

}

void NumberArray::storeNumber(float num,int ele)

{

if(ele<arraySize)

*(aptr+ele)=num;

}

float NumberArray::retrieveNumber(int ele)

{

return *(aptr+ele);

}

float NumberArray::getHighest()

{

float high=*(aptr+0);

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

if(high<*(aptr+i))

high=*(aptr+i);

return high;

}

float NumberArray::getLowest()

{

float low=*(aptr+0);

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

if(low>*(aptr+i))

low=*(aptr+i);

return low;

}

float NumberArray:: getAverage()

{

float ag=0;

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

ag+=*(aptr+i);

ag=ag/arraySize;

return ag;

}

//Header file section

#include <iostream>

using namespace std;

int main()

{

const int SIZE = 10; // Array size

// Define an IntArray with 10 elements.

NumberArray table(SIZE);

//function call to store values

table.storeNumber(1,0);

table.storeNumber(3,1);

table.storeNumber(7,2);

table.storeNumber(2,3);

//display values

cout<<"Highest value:"<<table.getHighest()<<endl;

cout<<"Lowest Value:"<<table.getLowest()<<endl;

cout<<"Average:"<<table.getAverage()<<endl;

///pause system for a while

system("pause");

return 0;

}

6 0
2 years ago
Which number is the decimal equivalent of 1100110 – 101101?
erastovalidia [21]

1100110-101101 = 111001 = 57

3 0
2 years ago
Read 2 more answers
A researcher plans to identify each participant in a certain medical experiment with a code consisting of either a single letter
trapecia [35]

Answer:

5 Letters

Explanation:

So we need 12 distinct codes made of a single letter or a pair of letters.

What would be the least number of letters?

Lets try with 3 letters A, B and C

The possible combinations are: A, B, C, AB, AC, BC

These are 6 codes and we need 12 so lets try more A, B, C and D

The possible combinations are: A, B, C, D, AB, AC, AD, BC, BD, CD

These are 10 codes and we need 12 so lets try more A, B, C, D and E

The possible combinations are:

A, B, C, D, E, AB, AC, AD, AE, BC, BD, BE, CD, CE, DE

Finally we got 15 distinct codes which are more than 12 so the least number of letters needed are 5.

Using formula:

Four letters = 4C1 + 4C2 = 4 + 6 = 10

Five letters = 5C1 + 5C2 = 5 + 10 = 15

5 0
2 years ago
Computer Networks - Queues
lyudmila [28]

Answer:

the average arrival rate \lambda in units of packets/second is 15.24 kbps

the average number of packets w waiting to be serviced in the buffer is 762 bits

Explanation:

Given that:

A single channel with a capacity of 64 kbps.

Average packet waiting time T_w in the buffer = 0.05 second

Average number of packets in residence = 1 packet

Average packet length r = 1000 bits

What are the average arrival rate \lambda in units of packets/second and the average number of packets w waiting to be serviced in the buffer?

The Conservation of Time and Messages ;

E(R) = E(W) + ρ

r = w + ρ

Using Little law ;

r = λ × T_r

w =  λ × T_w

r /  λ = w / λ  +  ρ / λ

T_r =T_w + 1 / μ

T_r = T_w +T_s

where ;

ρ = utilisation fraction of time facility

r = mean number of item in the system waiting to be served

w = mean number of packet waiting to be served

λ = mean number of arrival per second

T_r =mean time an item spent in the system

T_w = mean waiting time

μ = traffic intensity

T_s = mean service time for each arrival

the average arrival rate \lambda in units of packets/second; we have the following.

First let's determine the serving time T_s

the serving time T_s  = \dfrac{1000}{64*1000}

= 0.015625

now; the mean time an item spent in the system T_r = T_w +T_s

where;

T_w = 0.05    (i.e the average packet waiting time)

T_s = 0.015625

T_r =  0.05 + 0.015625

T_r =  0.065625

However; the  mean number of arrival per second λ is;

r = λ × T_r

λ = r /  T_r

λ = 1000 / 0.065625

λ = 15238.09524 bps

λ ≅ 15.24 kbps

Thus;  the average arrival rate \lambda in units of packets/second is 15.24 kbps

b) Determine the average number of packets w waiting to be serviced in the buffer.

mean number of packets  w waiting to be served is calculated using the formula

w =  λ × T_w

where;

T_w = 0.05

w = 15238.09524 × 0.05

w = 761.904762

w ≅ 762 bits

Thus; the average number of packets w waiting to be serviced in the buffer is 762 bits

4 0
3 years ago
Other questions:
  • How can you find Web pages that contain news published during the past week?
    8·1 answer
  • Derek has an interest in designing video games. What requirements should he fulfill to be a game designer?
    13·1 answer
  • Using ajax technologies and apis, websites and applications can pull information from a variety of sources in order to create __
    8·1 answer
  • you just bought a new hard drive for your computer you plan to use this as a second hard drive to store all your you made files
    6·1 answer
  • Design a program that asks the user to enter a store’s sales for each day of the week. The amounts should be stored in an array.
    10·1 answer
  • Gabriel needs to create a formula that does not change when it is copied to cell b2. which formula should he create?
    14·1 answer
  • Explain why the intangibility of Software System poses special problems for Software Project Management
    11·1 answer
  • Write the definition of a function named fscopy. This function can be safely passed two fstream objects, one opened for reading,
    11·1 answer
  • You have been supporting CSM Tech Publishing's Windows Server 2016 server network for over a year. The office has two Windows Se
    12·1 answer
  • Blockchain is often associated with Bitcoin and the financial services industry. However, it is applicable to almost every indus
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!