132k views
0 votes
Use POST/GET or Request method on the following and also use php language . show complete code and output 6. Write a program that will derive the number of years, months and days from an input in days. Use 365 as the total number of days a year.

7. Write a program that will get the double, square and half of a number supplied.
8. Write a program that reads two integers. Get their halves, quarter, double and square.
9. Using the conversion below, create an application that will ask for a pint value and will display its equivalence in gill, quarts and gallon. Format your output to have two decimal places.
1 pint = 4 gills
= ½ quarts
= 1/8 gallon
10. Make an application that will get a radius of a circle and will compute the diameter, circumference and area of the circle. Format your output to have two decimal places

User Narcy
by
7.6k points

1 Answer

3 votes

Final answer:

To derive the number of years, months, and days from an input in days, you can use the given steps and PHP code.

Step-by-step explanation:

To write a program that will derive the number of years, months, and days from an input in days, we can use the following steps:

  1. Take the input in days from the user.
  2. Divide the input by 365 to get the number of years.
  3. Take the remainder after dividing the input by 365 and divide it by 30 to get the number of months.
  4. Take the remainder after dividing the input by 30 to get the number of days.
  5. Print the number of years, months, and days.

Here's the code in PHP:

<?php
$input = 800;

$years = floor($input / 365);
$months = floor(($input % 365) / 30);
$days = ($input % 365) % 30;

echo "Years: " . $years . " Months: " . $months . " Days: " . $days;
?>

The output for the input 800 will be: Years: 2 Months: 2 Days: 10

User Drack
by
7.4k points