Enter no of hours days months years contains pattern , Programming Languages

Enter number of hours and find days, months and years.

 

echo -e "Enter Hours: \c"

read hr

echo "hour=$hr"

day=0

mon=0

yr=0

yr=`echo "$hr/365" | bc `

tmp=`echo "$hr%365" | bc`

mon=`echo "$tmp/30" |bc`

day=`echo "$tmp%30" | bc`

echo -e "$hr hours =  $yr years and  $mon months and  $day days"

 

Output

sh cnthour.sh

Enter Hours: 450

hour=450

450 hours =  1 years and  2 months and  25 days

 

sh cnthour.sh

Enter Hours: 370

hour=370

370 hours =  1 years and  0 months and  5 days

 

Posted Date: 9/26/2012 8:36:58 AM | Location : United States







Related Discussions:- Enter no of hours days months years contains pattern , Assignment Help, Ask Question on Enter no of hours days months years contains pattern , Get Answer, Expert's Help, Enter no of hours days months years contains pattern Discussions

Write discussion on Enter no of hours days months years contains pattern
Your posts are moderated
Related Questions
Determine the solution to the following differential equation. x 2 y′′ + 3xy′ + 4 y = 0   Solution Find the roots to (3) first as generally. r(r -1) + 3r + 4 = 0 r

Question 1 Discuss on Inheritance Question 2 What are the four phases of the object modeling technique that can be repetitively executed? Question 3 Explain the di

Write a program that takes integer array of 8 elements from user and find the smallest element among them using pointers

Write a program (calculation.ccp) to allow the user to perform an arithmetic operation on the two complex numbers entered.  The user can key in one of the four operations: addition

In this portion of the lab you will analyze a problem and create a Raptor program to solve it.  Make sure you use a class in Raptor and in Python to solve the problem.  Read the fo

We want to create a structure that will represent a deck of cards  (not necessarily full). Each card has a character (between  '2'  to  '9' and  'T',  'J',  'Q',  'K',  'A') and a

Microsoft Intermediate Language in .NET When you create value in any terminology and gather, it will be changed to an 'Intermediate Language' (Microsoft Advanced Language - MSIL

how to store an url in a dartabase(sql server 2005)? (or) create table b(url what is the datatype for url?

Redundant sequence identification: Given a set of k DNA sequences, S = { s 1, s 2, ... ,  s k } give an optimal algorithm to identify all sequences that are completely contained

how to save bulk entries at a time using collections?