Answer:
In Java
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int mnth, yr;
Scanner input = new Scanner(System.in);
System.out.print("Month: "); mnth = input.nextInt();
System.out.print("Year: "); yr = input.nextInt();
boolean lpYear = (yr % 4 == 0 && yr % 100 != 0) || (yr % 400 == 0);
if(mnth == 1 || mnth == 3 || mnth == 5 || mnth== 7 || mnth == 8 || mnth == 10 || mnth == 12){
System.out.print("31 days"); }
else if(mnth == 2){
System.out.print(((lpYear) ? "29 days" : "28 days")); }
else if(mnth == 9 || mnth == 6 || mnth == 4 || mnth== 11){
System.out.print("30 days"); }
else{ System.out.print("Invalid"); }
}
}
Explanation:
See attachment for complete program where comments were used as explanation.
Answer:
The working principle of the computer system. Computers do the work primarily in the machine and we can not see, a control center that converts the information data input to output. This control center, called the central processing unit (CPU), How Computers Work is a very complex system.
Explanation:
Answer:
See Explaination
Explanation:
#include <stdio.h>
MphAndMinutesToMiles()
{
double milesPerHour;
double minutesTraveled;
double hoursTraveled;
double milesTraveled;
scanf("%lf", &milesPerHour);
scanf("%lf", &minutesTraveled);
hoursTraveled = minutesTraveled / 60.0;
milesTraveled = hoursTraveled * milesPerHour;
printf("Miles: %lf\n", milesTraveled);
}
int main()
{
MphAndMinutesToMiles();
return 0;
}
Answer:
phrase[2:5]
Explanation:
Given:
The above code segment
Required
Which instruction returns 'u a'
First, we need to get the index of u in the phrase:
u is at the third position but in programming, index starts at 0.
So, u is at index 2
Next, we need to get the index of a in the phrase:
a is at index 4
One of the ways to return a sub string from a string in python is ![string[start:stop+1]](https://tex.z-dn.net/?f=string%5Bstart%3Astop%2B1%5D)
Where:
----- index of u
----- index of a
phrase ---- The string variable
So, the instruction that returns 'u a' is: ![phrase[2:5]](https://tex.z-dn.net/?f=phrase%5B2%3A5%5D)
<em>Where 5 = 4 + 1</em>
Answer:
Check the explanation
Explanation:
Answer: Solution: Algorithm:
Step 1: Start.
Step 2: Create a stack Step
3: Push an initial stack variable, it will represent that, stack is empty.
Step 4: Get input
If +1 then push "+1"
Else if -1 then pop
Step 5: Repeat until all input finish or Stop if empty stack variable popped. Step 6: Stop.
It is a pushdown automata problem.
It can be also represented as:
X =1+1* —1* 1No(+1)>= No(-1)}