if, no loops)Here are three sample execution logs of the sought system:
Enter satellite's altitude in km: 1000 Orbital Period = 1 hours, 45 minutes and 5.7 seconds. Enter satellite's altitude in km: 35800 Orbital Period = 23 hours, 56 minutes and 29.0 seconds. Enter satellite's altitude in km: 500000 Orbital Period = 995 hours, 56 minutes and 21.0 seconds.The mathematical formula to compute the orbital period P (in seconds) in terms of the altitude A (in kilometers) is: P = K(A + R)^(3/2) where K = 0.00995 is the Kepler constant and R=6378 is the Earth radius.
Note: Your program output must be formatted
exactly as shown here; i.e. the field width of the hours output, one
decimal for the seconds, and inter-word spacing.
Hint: Start by ignoring the hour / minute / second and output the
period in seconds. Once you are satisfied it is working properly,
refine the output so it produces the desired breakdown.
if, no loops)
$50 $20 $10 CHARGE
--- --- --- ------
2 1 1 2.60
Write a Fortran program to control the ATM as follows: read an amount
from the user (an integer), compute the number of bills for each
denomination and then print out a table as shown above. The program should
be friendly as well as robust; i.e. gives clear prompts and doesn't crash
if the user's entry is meaningless (e.g. negative).
if statement, loops)if statement, loops)
Number of integers: xxxx
Largest integer: xxxx
Smallest integer: xxxx
Arithmetic Mean: xxxx.xx
Standard Deviation: xxxx.xx
Note that the last two are real numbers. The standard deviation
is the square root of the variance, which is defined as the mean
of the squares (of the numbers) minus the square of the mean.
Format the output exactly as shown above. You may assume that
all entered integers have up to 4 digits plus sign.
if statement, loops)ATGTTTAAAGCTAAAGCTGATAAACCG. Output is: AAA.
string functions)
integer*2 function trimLength(str)
implicit none
character*(*) str
which receives a string str of arbitrary length (set in the
caller's declaration) and returns its length excluding any trailing
spaces. Hint: scan the string right to left.
string functions)
logical*1 function isDigit(str)
implicit none
character*(*) str
which receives a string str of arbitrary length (set in the
caller's declaration) and returns true if, aside from any
trailing spaces, the string is made up exclusively of digits. It returns
false otherwise. Hint: create a string containing all
10 digits and then use the index function to ensure that
every character in str is contained in the digits string.
string functions)
integer*4 function s2n(str)
implicit none
character*(*) str
which receives a string str of arbitrary length (set in the
caller's declaration) and returns its numeric value. Aside from trailing
spaces, the received string must contain only digits or else zero is
returned. Hint: benefit from the two functions above.
string functions)
character*11 function n2s(n)
implicit none
integer*4 n
which receives an integer n and returns it as a string;
i.e. if n=-1200, the return is the 5-character string "-1200".
real*4 function sin
implicit none
integer*4 n
which computes the infinite sum: 1 - x2/3! + x4/5! -
... (terms alternate in sign and each is an even power of x divided by
the factorial of the next odd number), given x and a tolerance; i.e.
stop adding terms when the term to be added is less than tol in abs val.
function and subroutine
subprograms)getInteger: a subroutine that prompts and reads
the integer and returns it along with a logical set based on the
entry's sign (set to true if positive).
s2n: defined above.
n2s: defined above.
reverse: a function that takes a string of 11 characters
and return it (without any trailing characters) reversed. The function's
return is also 11 character in length; i.e. if you send "12" followed
by 9 spaces, the return is "21" followed by 9 spaces.
function and subroutine
subprograms)getProd: a subroutine that prompts and reads
the desired product and returns it along with a logical set based on the
entry's value (set to true if between 0 and 729).
ranPlate: a function that returns a random character*6
string. It doesn't have to adhere to the above format.
isDigit: defined above.
isCAP: a logical function that receives a string of
arbitrary length and return true if the string is
made up of capitals letters other than I,G,Q.
function and subroutine
subprograms)weight: an integer*2 function that returns the weight
of the current letter (or zero if none).
destination: a character*2 function that returns the
destination code of the current letter.
charge: an integer*2 function that receives the weight and
destination code of a letter and return the shipping charge (in dollars).
stamp: a subroutine that receives the letter's data
(weight, dest. code, and charge) and simulate stamping the letter by
printing the letter's data on one line of the screen.
integer*2 ds, as
character nAR(500)*25, pAR(500)*15
parameter (ds = 500)
The variable ds (declared size) sets the upper limit on the database
size, while as (actual size) specifies how many contacts are currently
present in the database. The two partially-populated arrays hold the
names and telephone numbers of all contacts are kept parallel at all
times. The order of entries in the database is unimportant. Sorting is
done upon reporting. The following subprograms are needed:integer*2 function lookup(nAR,pAR,ds,as,name)name is not present in the name array, or its index
if present.
subroutine insert(nAR,pAR,ds,as,name,tel,result)name is already in the array then do nothing but
set result=0. If as
is less than name, then also do nothing but set
result=-1. Otherwise, insert the passed name and
tel in the two arrays, increment as, and set
result=1. Insertion is done by appending.
subroutine delete(nAR,pAR,ds,as,name,result)name is not present in the array then do nothing but
set result=0. Otherwise, remove the passed name
(and corresponding entry in pAR), decrement as,
and set result=1. Deleting the element at index k is done
by overwriting it by that that at index as.
subroutine report(nAR,pAR,ds,as)subroutine sort(nAR,pAR,ds,as)