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
tatyana61 [14]
2 years ago
5

The date June 10, 1960, is special because when it is written in the following format, the month times the day equals the year:

6/10/60 Design a program that asks the user to enter a month (in numeric form), a day, and a two digit year. The program should then determine whether the month times the day equals the year. If so, it should display a message saying the date is magic. Otherwise, it should display a message saying the date is not magic.
2. Running on a particular treadmill you burn 3.9 calories per minute. Write a program that uses a loop to display the number of calories burned after 10, 15, 20, 25, and 30 minutes.

Computers and Technology
1 answer:
MrRa [10]2 years ago
7 0

Answer for Question 1:

Code for the first question:

#section 1

<em># Prompt for accurate day month and year </em>

<em>while True: </em>

<em>    try: </em>

<em>        day = int(input("Enter the day of month: ")) </em>

<em>        if day > 31 or day < 1: </em>

<em>            raise </em>

<em>        try: </em>

<em>            month = int(input("Enter the month in numeric form: ")) </em>

<em>            if month > 12 or month < 1: </em>

<em>                raise </em>

<em>            try: </em>

<em>                year = int(input("Enter the year in two digit format: ")) </em>

<em>                if year > 99 or year < 0: </em>

<em>                    raise </em>

<em>                else: </em>

<em>                    break </em>

<em>            except: </em>

<em>                print("Error: invalid year input.") </em>

<em>        except: </em>

<em>            print("Error: invalid month input.") </em>

<em>             </em>

<em>    except: </em>

<em>        print("Error: invalid day input.") </em>

<em> </em>

<em># We have a valid date, lets determine whether it's magic or not </em>

<em> </em>

<em>#Section 2 </em>

<em># Calculate the mutliplication of day and month </em>

<em>dayxMonth = day * month </em>

<em> </em>

<em># Display the results to the screen </em>

<em>print() </em>

<em>print("The date ", day, "/", month, "/", year, end=" ") </em>

<em />

<em />

<em># Calculates whether the entered date is a magic date </em>

<em>if dayxMonth == year: </em>

<em>    print ("is a magic date.") </em>

<em>else: </em>

<em>    print ("is not a magic date.") </em>

Explanation for Question 1:

#section 1

The Try and Except block in combination with the while loop is used to ensure that all inputs are accurate if there is an error in the input, it prompts the user to enter a valid input and states the problem with the input.

Each try block contains an if statement for day, month and year respectively.

<em />

#Section 2

calculates the multiplication of  day  and month,

compares it with the year to find out if it's magic and finally prints the result to the screen

Answer for Question 2:

Code for the second question:

<em>print("Time   Calories Burned in minutes") </em>

<em>print("----   ---------") </em>

<em>for time in range(10,31,5): </em>

<em>    cburn=3.9*time </em>

<em>    print(time,cburn,sep='      ')</em>

<em />

Explanation for Question 2:

  • <em>for time in range(10,31,5): </em>

A for loop is used to iterate over a range of values.

from 10 to 31 and the skipper is 5.

The skipper is how many numbers are skipped before the for lop takes another value from the range.

  • <em>  </em><em>cburn=3.9*time </em>

<em>                print(time,cburn,sep='      ')</em>

the values provided by the range are 10, 15, 20, 25, and 30 minutes.

we then calculate the calories for each value and print then to the screen.

You might be interested in
Which browser do most web users use and why do you think that it is that way? Make sure you search online for statistics to conf
oksian1 [2.3K]

Answer:

2b2t

Explanation:

2b2t

4 0
3 years ago
What are the risks associated with this kind of connectivity?.
Eva8 [605]

Answer:

The risks associated with this kind of connectivity are that online hackers may see your information and that makes the human race too dependent on robots and technology which is never a good thing.

Explanation:

<h3>be happy</h3>
8 0
2 years ago
Write a program that reads a file name from the keyboard. The file contains integers, each on a separate line. The first line of
Sindrei [870]

Answer:

Explanation:

import java.util.Scanner;

import java.io.*;

public class ArrayProcessing

{

public static void main(String[] args) throws IOException

{

Scanner kb = new Scanner(System.in);

String fileName;

System.out.print("Enter input filename: ");

fileName = kb.nextLine();

File file = new File(fileName);

if(!file.exists())

{

System.out.println("There is no input file called : " + fileName);

return;

}

int[] numbers = inputData(file);

printArray(numbers);

}

public static int[] inputData(File file) throws IOException

{

Scanner inputFile = new Scanner(file);

int index = 1;

int size = inputFile.nextInt();

int[] values = new int[size];

while(inputFile.hasNextInt() && index < values.length)

{

values[index] = inputFile.nextInt();

index++;

}

inputFile.close();

return values;

}

public static void printArray(int[] array)

{

int count = 1;

for (int ndx = 1; ndx < array.length; ndx++)

{

System.out.printf("%5.f\n", array[ndx]);

count++;

}

if(count == 10)

System.out.println("");

}

}

4 0
3 years ago
What information is contained in the title bar
Varvara68 [4.7K]

Answer:

like the url i think

Explanation:

8 0
2 years ago
What is wrong in the following code? class TempClass { int i; public void TempClass(int j) { int i = j; } } public class C { pub
Rom4ik [11]

Answer:

In the given program,  a parameterized constructor declaration is wrong, which can be described as follows:

Explanation:

Code:

class TempClass //defining class TempClass

{

   int i; //defining integer varaible i

   TempClass(int j)//defining parameterized constructor

   {

   i = j; //variable holds a value

   System.out.print(i); //print value

   }

}

public class Main //defining class Main

{

   public static void main(String[] aw) //defining main method

   {

       TempClass temp =new TempClass(2); //creating class Object and call parameterized constructor.

   }

}

Description:

  • In the given java code, two classes "TempClass and Main" is defined, inside the TempClass class an integer variable "i" and a parameterized constructor is declared, inside the constructor integer variable "i"  hold constructor parameter value, the use print method to prints its value.  
  • Then the main class is defined, inside this main method is declared, in this method, the TempClass object "temp" is defined, that call the parameter constructor.
7 0
3 years ago
Other questions:
  • Which major milestones started off the progression that led to the modern computers we play games on now? What do you think affe
    14·1 answer
  • Give the difference betewen recursion and interation in C. Sight what are the advantages and their disadvantages?
    7·1 answer
  • Peter is a data analyst in a financial firm. He maintains a spreadsheet that contains all employee details. Peter wants to analy
    9·1 answer
  • What is responsible for making an axle spin in an electric motor? an outside power source attached to a magnet an outside power
    6·2 answers
  • What is variable declaration in java ​
    6·2 answers
  • Please create C program, the task is to implement a function edoublepowerx that has an input parameter x of floating-point value
    11·1 answer
  • A model is replica that?
    11·2 answers
  • While reviewing the Quick Access toolbar, Sarah notices that the Redo button is not there. This is because the Redo button only
    12·1 answer
  • 3.19 LAB: Seasons In C++ Write a program that takes a date as input and outputs the date's season. The input is a string to repr
    15·1 answer
  • Colours can be contrasting if<br>​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!