-
Question:
Software development process:
1.
Problem
statement:
-
In
this program, a defined structure type contained
five elements which
represent the
feature of an element. User need to input the
arbitrary
numbers of the element with
the information with the instruction
demonstrated in the screen. These five
elements will be store in the variable
with the structure type. After input
these elements, the elements with its
information will be listed in order
2.
Analysis:
?
Input:
-
An arbitrary
integer which represents the number of element,
information
about the input elements.
?
Output:
-
The information
about each element input by user will be output in
order
?
Additional requirement:
-
None (Be
careful to input valid data. If an integer is
required to be input, a
non-integer was
input, then user will be required input again)
3.
Algorithm:
-
Define a
structure type namely
element
in which there are five elements,
The five elements are:
Number
–
atomic number of the input
element
Name
–
name of the
input element
Symbol
–
chemical symbol
of the input element
Weight
–
atomic weight of the
element
Shell
–
the number of electrons in each shell
-
Declare a array
namely
atom
of the type of
structure element
-
Define a
is_integer
function to check
if the input number is an integer
-
Define a
clrscr
function to clean the
screen
-
Define a
scan
function to read and store the information about
the element
input by
user
.
-
Define a
print
function to output the
information about the element in order
input by user
-
Define a main
function with no arguments and return value. The
process of
input and output will be
conducted in the body of the main
function.
-
To ask user input the number of
elements and the information about each
element.
-
Output the
information about the element in the
screen
Flowchart:
Is_integer
function:
start
I = 0
j =
0
*str==
'-'
I =
I+1
Str = str+1
isdigit(*str)
*str
==0
==
’
0'?
I ==
0
Y
N
Return
1
Return 0
End
Scan
function:
Print
“
please
type the atomic
number of
element:
”
Ask user to input
an
integer and store it
in
variable
‘
s
’
X=s
Input a integer and
store it in
‘
s
’
Y
is_integer(x)=0?
Input a integer and
store it in
‘
s
’
Y
is_integer(x)=0?
X=s
Ask user
to input
an integer and
store it in variable
‘
s
’
Atoi(s)>118?
Input
the
atomic
number
X=s
Input a integer and
store it in
‘
s
’
Y
is_integer(x)=0?
Input a integer and
store it in
‘
s
’
Y
is_integer(x)=0?
X=s
Ask user
to input
an integer and
store it in variable
‘
s
’
Atoi(s)>118?
Input
the
atomic
name
Input
the
chemica
l symbol
Input
the
atomic
weight
Input
number of
electrons in
each array
end
Print
function:
start
print the
atomic
number
print the
name of
element
print the
chemica
l symbol
print the
atomic
number
m=m+1
print
the
number of
electrons in
m
shell
m<7
End
4.
Implementation: see c codes in file 1.c
with comments
5.
Testing:
This
program was tested by input a set of data, the
output of this program was
verified
very successful. For example:
Enter this program:
Input the
information about the 1th element:
Input the information about
the 2th element:
The
output of this program:
When user is asked to input the number
of element, a non-integer was input:
-
-
-
-
-
-
-
-
-
上一篇:看会了这些,你就是pads高手概述
下一篇:C语言开发规范