Free Essay

Programming

In: Computers and Technology

Submitted By megasyllable
Words 1404
Pages 6
Programming 1 - Semester 1, 2015
Assignment 1
Release Date: 27 / 02 /2015
Total raw marks: 60
Assignment weight: 6%
NOTE: This assignment is to be undertaken individually—no group work is permitted.

Background information
For this assignment you are to complete a partially completed menu-driven, Java console application, which allows the user to select one of four options:





Display Time and Date
Swim Fitness Summary Calculator
Sentence Analyser
Exit

The incomplete code solution (in the source file called MenuDrivenProgram.java) is in the same
Assignment 1 folder, available via myRMIT.
The partially completed program already has code to display the menu. You should study the code and then compile and execute it without implementing the following options. This will allow you to understand the flow of execution of the program, as is.
a)

Once the processing for the selected option has been completed the program should return to the menu (that is, the program should not terminate).

b)

You do not need to handle runtime errors of any kind for this assignment and you may assume that the user will always enter input in the correct format. This applies both to the menu itself and the processing of the menu options.

Program Features
Menu Option A - Display Time and Date (10 marks)
The program should retrieve the current time and date from the system and then display it in the format shown below:
+++++++++++++++++++++++++++++++++++++++++
+
Mon 23 Feb 20:46:02 AEDT 2015
+
+++++++++++++++++++++++++++++++++++++++++
You are encouraged to do a little research on how to retrieve the current time and date in the required format - it is permitted to discuss different approaches in the forums / facebook group but to not share your actual code.
1

Menu option B - Swim Fitness Index Calculator (15 marks)
The program should prompt for and accept the values for the number of laps swum by the person in question, their weight (in kg) and the time it took to swim the specified number of laps (no validation is required here).
Once the required values have been read in the program should to calculate the relative swim fitness index (in terms of laps per minute per kg) as follows and displayed to the screen:

swim fitness index = (number of laps / time) / weight
Once the swim fitness index has been calculated and displayed the program should determine whether the swim fitness index for the session was less than, equal to or greater than a benchmark swim fitness index that has been set of 0.025 - a suitable message should be displayed to the screen accordingly indicating swim fitness index for the session was below, equal to, or above the benchmark that has been set.
Examples are given below for the different scenarios.
Example 1 - fitness level decreasing:
Enter number of laps: 40
Enter time taken in minutes: 25
Enter weight in kg: 80
Swim fitness level achieved in session was 0.02
Session swim fitness index was below the benchmark swim fitness index by 0.005
Example 2 - fitness level unchanged:
Enter number of laps: 40
Enter time taken in minutes: 20
Enter weight in kg: 80
Swim fitness level achieved in session was 0.025
Session swim fitness index equalled the benchmark swim fitness index
Example 3 - fitness level decreasing:
Enter number of laps: 50
Enter time taken in minutes: 25
Enter weight in kg: 50
Swim fitness level achieved in session was 0.04
Session swim fitness index was above the benchmark swim fitness index by 0.015

Note that the user may enter different values for the number of laps, time and weight.

2

Menu option C – Sentence analyser (20 Marks)
The program should initially prompt the user to enter a sentence, reade that sentence in from the keyboard and store it in a variable for later use.
Once the sentence has been read in the program should produce an analysis of the structure of the sentence by calculating and displaying the following statistics:


The length of the sentence



The number of upper and lower case letters in the sentence



The number of digits in the sentence



The number of whitespace characters in the sentence



Whether the sentence is a valid sentence or not - any sentence ending in a period ('.'), a question mark ('?') or an exclamation point ('!') is considered to be a valid sentence for this purposes of this task.

A sample run is shown below to demonstrate how the program should run:
Enter sentence: The quick BROWN fox jumped over the 2 lazy dogs (or was it 3?).

Sentence statistics:
- Length of sentence:
- Upper case characters:
- Digits:

63
6
3

- Lower case characters: 39
- Whitespace characters: 13
- Valid sentence:
YES
Note that this sample execution run is presented for example purposes – the user may specify a sentence that contains different number of the character types you are looking for and may or may not be a "valid" sentence based on the criteria mentioned above.

3

Code commenting / General coding style (7 + 4 + 4 = 15 marks)
Coding style (7 marks)
You should adhere to the following coding style guidelines when implementing your program for this assignment.
A. Different indexs of program scope (methods, control structures, etc) should be indented consistently using indexs of 3 or 4 spaces (do not use tabs).
B. A new index of indentation should be added for each new class/method/control structure that is
“opened”.
C. Indentation should return to the previous index of at the end of a class/method/control structure
(before the closing brace if one is being used).
D. Block braces should be aligned and positioned consistently in relation to the method/control structure they are opening/closing.
E. Lines of code should not exceed 80 characters in length (including indentation) - lines which will exceed this limit are split into two or more segments where required.
F. Expressions should be well spaced out – this includes assignment statements, arithmetic expressions and parameter lists supplied to method calls.
G. Source code should be spaced out into logically related code segments.
H. Identifiers used in the program for class/method/variable/constant names should adhere to the naming conventions discussed in the course notes.
I. Identifiers themselves should be meaningful without being overly explicit (long) – you should avoid using abbreviations in identifiers as much as possible (an exception to this rule is a
“generic” loop counter used in a for-loop).
Menu Code Commenting (4 marks)
You are required to demonstrate your understanding of the sample menu code that was provided by including suitable brief (1-2 line) comments describing each logical step that this sample menu code follows.
You will be graded here based on how clearly and effectively you describe the sample menu with comments - this requires you to describe the purpose of each logical segment in the sample menu code to discuss the steps that it takes, rather than just recounting the statements / structures in the code itself.
General Commenting (4 marks)
You should also include brief (1-2 line) comments describing what each logically related segment of code in the parts of the program you have implemented are doing.
Remember that comments should generally be placed on the line above the statement(s) or code segment they refer to avoid cluttering up your lines of actual program code.

4

Submission details
This assignment will be graded out of a total of 60 marks and contributes 6% towards your final result for this course.
This assignment is not a hurdle in itself, rather it contributes towards the practical work component for this course (of which you must obtain 50% or better overall in order to pass the course). This assignment is due to be submitted via weblearn by 11:59pm on Sunday March 29 AEST.
There will be a late submission period of 5 days for this assignment, which will expire at 9:30am on Friday April 3 AEST.
Late submissions received before this deadline will incur a late penalty of 10% per day (or part thereof), unless some prior arrangement has been made with the head tutor regarding an extension. Late penalty deductions will be applied to the marks awarded for the assignment, rather than the total marks available for the assignment.
Submissions received after the late submission deadline period will not be assessed unless prior arrangements have been made for an extension.
All queries regarding this assignment should be directed to the Assignment 1 forum in blackboard.

5

Similar Documents

Premium Essay

Programming

...flowcharts to describe a program’s structure. Use pseudocode to define a program’s structure. Formulate solution algorithms for calculations by properly following the order of operations. Assignment Requirements Answer: * Short Answer 1, 2, 3, and 4 on page 71 * Algorithm Workbench Review Questions 1 and 2 on page 71 * Programming Exercises Questions 1 and 4, starting on page 72 Required Resources Textbook Submission Requirements Submit your written answers to your instructor at the beginning of Unit 3. Unit 2 Research Assignment 1: Researching Variable Naming Rules Learning Objectives and Outcomes Determine program input, processing, and output stages. Create the necessary flowcharts to describe a program’s structure. Use pseudocode to define a program’s structure. Formulate solution algorithms for calculations by properly following the order of operations. Assignment Requirements Use the Internet and the ITT Tech Virtual Library to research the following questions: What are the variable naming rules of Visual Basic, Python, and Java? List three similarities and differences in between the three programming languages. Required Resources Textbook ITT Tech Virtual Library: http://library.itt-tech.edu Submission Requirements Submit your written answers to your instructor at the beginning of Unit 3. Labs Unit 2 Lab 2.1: Pseudocode Learning Objectives and Outcomes * Use pseudocode to define a program’s structure. * Formulate...

Words: 450 - Pages: 2

Free Essay

Programming

...the module in which its declared and only statements inside that module can access that module can access the variable. 5. The local variable usually beings at the variables declaration and ends at the end of the module which is then the variable is declared. 6. The difference between the both is that only a copy of the arguments value is passed and passing by reference means that the argument is passed into a specific type of parameter. 7. Global variables make debugging difficult because they make programming hard to understand, modules that use global variables are usually dependent and you have to track down every statement. Algorithm Workbench 1. Module main() Declare userNum as Integer Display “Enter a number” Input userNum Call TimesTen(usernum) Display usernum End 5. 13.4 00.0 00.0 6. 1, 3.4 0, 0 0, 0 7. Allows changes the values of passed parameters 1,3.4 0,0 0,0 Doesn’t allow changing of parameters 1,3.4 0,0 1,3.4 Programming Exercises 1. Kilo=input (“Enter distance in kilometers”) Miles=Kilo Print”, Kilo 2. Module TotalPurchase Declare Double amount, total Declare TAX=.06 While I<6 Display “Enter the price” Input amount Total=total+amount I=I+1 End while Display “Subtotal is:” + total Display “Tax is:” + (total*TAX) Display “Total is:”=(total*TAX)+total) End...

Words: 309 - Pages: 2

Free Essay

Programming

...Calling an external function or program that is written in a different programming language like a Java program within a Visual Basic program you first need to know the Function fundamentals that’s executed in any programming language. I came across this website called maples, where they have the ability to connect to and call functions from other programming languages. Maple uses this for various reasons. Like all other languages, the F# function has a name, it can have parameters, has a body and takes arguments. F# also supports functional programming constructs such as handling functions as values, depleting unnamed functions in expressions, composition of functions to form new functions, curried functions, and the implicit definition of functions by way of the partial application of function arguments. Maple's help system documents all the External Calling functions so you can see what is available. Briefly, however there are functions for converting Maple types to C and back, creating and interacting with Maple data structures creating and interacting with Maple language elements (names, procedures, etc), printing to the Maple interface, memory allocation, evaluating Maple statements and raising exceptions. There is even a C interface to the Task Programming Model. The function-name is an identifier that represents the function. The parameter-list consists of successive parameters that are separated by spaces. You can specify an explicit type for each parameter, as described...

Words: 394 - Pages: 2

Free Essay

Programming

...Introduction Selection structures allow computer programs to perform different functions depending on if the condition of the function is true or false. Selection structures also enable the program to decide on a particular action based on the input of the user or other processes. There are several different types of selection structures that can be put into operation, they are the IF selection statement, the IF ELSE selection statement and switch selection statement. This paper will attempt to explain selection structure and its different types and will also give a real life scenario in pseudo code. Selection Control Structure Computer programs utilize selection structures to choose from a variety of actions or processes. These processes typically have an outcome of true or false. When a program reads as true the process will be directed to the output that enables it to be true and vice versa for false processes. With computers having the ability to solve problems, make decisions and follow direction with the aide of a program it eliminates many human errors. The “IF” selection statement structure is used when there is a solitary or a collection of inputs to be executed to decide if the condition is true or false. If a process is submitted as false the “IF else” statement is rendered and the false output is passed over and the computer continues executing to the next selection structure. The IF statement structure also compares two values with relational operators: •...

Words: 505 - Pages: 3

Free Essay

Programming

...Reverse engineering involves taking something apart to see how it works. The advantages are you can learn the kind of system functions a target program is using. You can learn the files the target program accesses. You can learn the protocols the target software uses and how it communicates with other parts of the target network. The most powerful advantage to reversing is that you can change a program's structure and thus directly affect its logical flow. The disadvantages would be by enabling competitors to create competing devices, the possibility of reverse engineering might decrease the incentive for technology creators to develop new products, and reducing the manufacturer’s control over consumer uses for the product might have the same effect. One tool is REC Studio 4 - Reverse Engineering Compiler some of the features are Disassembler, Disassembler, Calling conventions, Floating-point, Windows Debugger. Short Answer 5. The variable’s name, and the variable’s data type 6. Some languages assign a default value such as 0 to uninitialized variables. In many languages, however, uninitialized variables hold unpredictable values. Algorithm workbench review 3. set b = 2+a Set a = b * 4 Set b = a / 3.14 Set a = b – 8 4. a. Set result = x + y b. Set result = z * 2 c. Set result = y / x d. Set result = y – z result = x++   - y; Answer   -4 result = 4 – 8 = -4     result =   ++w + y; Answer w = w + 1 = 5 + 1 = 6 result = 6 + 8 = 14 5. Declare...

Words: 297 - Pages: 2

Premium Essay

Programming Languages

...Exploring Programming Languages Computers don't do anything without someone telling them what to do, much like the average teenager. To make the computer do something useful, you must give it instructions in either of the following two ways. When you write a program it tells a computer what to do, step by step, just as you would like when taking directions. When you buy a program that someone else has already written, it tells the computer what to do. Ultimately, to get a computer to do something useful, you (or somebody else) must write a program. A program does nothing more than tell the computer how to accept some type of input, manipulate that input, and spit it back out again in some form that humans find useful. Table 1 lists some common types of programs, the types of input that they accept, and the output that they produce. The five popular programming languages in the 1970’s were Pascal, C, SQL, KRL, and COMAL. Pascal is an influential imperative and procedural programming language, designed in 1968–1969 and published in 1970 by Niklaus Wirth. C (/ˈsiː/, as in the letter C) is a general-purpose programming language initially developed by Dennis Ritchie between 1969 and 1973 at AT&T Bell Labs. SQL was developed at IBM by Donald D. Chamberlin and Raymond F. Boyce in the early 1970s. SQL often referred to as Structured Query Language. KRL is a knowledge representation language, developed by Daniel G. Bobrow and Terry Winograd while at Xerox PARC and Stanford University...

Words: 839 - Pages: 4

Free Essay

Computer Programming

...Computer Programming Computers and machines have definitely changed people's lives over the years influencing academic life, workplace, and even the home setting. Therefore, it is important to become knowledgeable about computers and its different applications. Without doing so can severely affect one's chances in succeeding especially in his or her professional life since majority, if not all, of companies around the world depend on computers and machines. There are numerous jobs that deal specifically on the development of technology, including computers. One of the major careers in the field of computers is computer programming. People who work in this field are responsible for “writing, testing, and maintaining the instructions that computers follow to perform their functions. They also focus on conceiving, designing, and testing logical structures for solving problems by computer” (“Computer Programmers”). Literally, they program computers, softwares, and applications to function the way computers should. In 2007, “40 percent of companies expected to add programmers and information technologists, 45 percent expected to maintain their staffs, and 81 percent planned to increase the salaries of their computer programmers” (“The 2007 Job Market Outlook for Computer Programmers”). However, these numbers are not enough because it seems that the job outlook for this profession is not good. “The occupation is forecasted to grow more slowly than the average for all other occupations...

Words: 911 - Pages: 4

Premium Essay

Programming Timeline

...After researching the programming languages between the eras of 1970s-2000s I discovered there were many types of programming languages being developed at a spectacular rate. The popularity of the languages were dependent upon what you were trying to program. Below you will find a general idea of 5 programming languages and a brief description of those languages. 1970s- PASCAL • Designed in 1968-1969 • Published in 1970 by Niclaus Wirth • Historically influential and procedural programming language • Intended to encourage good programming practices using structured programming and data structuring • Influential imperative and procedural programming language 1980s- C++ (pronounced see plus plus) • Statically typed, free-form, multi-pariadigm, compiled, general-purpose programming language • Middle-level language o Comprises a combination of both high-level and low-level language features • Developed by Bjarne Stroustrup starting in 1979 at Bell Labs as an enhancement to the C programming language • Renamed C++ in 1983 • Has imerative, object-oriented, generic programming features • Provides low-level memory manipulation • For use in embedded systems or operating system kernels • Is a compiled language • Available on many platforms and provided by various organizations 1990s- JAVA • Originally developed by James Gosling at Sun Microsystems • Released in 1995 as core component of Sun Microsystems’ Java platform • Derives much of its syntax from C and...

Words: 470 - Pages: 2

Free Essay

Programming Solutions

...Programming Solutions Being able to create a solution to a certain problem through programming can be a huge task to undertake, but it is a task that must be accomplished in order to get certain things done. Many companies face problems in the IT field that can be solved through programming, from simple to very complex, these problems usually require some sort of input and variables in order to create a solution. One problem that I face in the workplace of construction, is trying to figure out the number of ceiling tiles we will need to fit the ceilings in most offices we build. The ceiling tiles are a certain size and cover large areas which can be a tedious task trying to count how many tiles it will take to fill in the ceiling. A programming solution could be very beneficial in an instance such as this because by creating inputs such as the size of the tiles and the area they need to cover, an output could be the number of tiles that will be needed and thus saving a large amount of time on counting every space they need to fill. This problem of having to determine the number of ceiling tiles it will take to cover the celling area is normally done by counting the spaces in the ceiling that need to be filled and then determining how many tiles will need to be purchased. By coming up with a program to solve this problem would no doubt save a lot of time and even money by not buying an excess amount and either throwing them away or storing them. I believe a simple program would...

Words: 701 - Pages: 3

Premium Essay

Benefits of Programming

...Benefits of Programming Knowledge John Padgett IT/ 215 August 8, 2013 Chan Benefits of Programming Knowledge When you are an IT professional, you really want to know as much as you can about your particular specialty as an IT member and you also need to have some knowledge in programming concepts as well. It really doesn’t matter what you do as an IT team member for a particular company, but as a member you need to have basic programming concept skills to be effective and understanding how to solve any problems that you may encounter. The main problem today for any IT division of a company is being able to support all aspects of IT that company may need. It starts with security for the company and its data all the way to systems managers and network engineers just to name a few of the positions that IT professionals have skills to perform those jobs within the companies IT team. Everything that you will do as an IT professional will require you to have some basic knowledge in programming concepts because just about all the areas in the IT field ultimately come down to programming the computer to do a specific function or task. If you don’t have the basic skills of programming concepts you will be lost when it comes to trouble shooting any problems. As an It professional you will come across many circumstances that will require you to have programming fundamentals to do the job required at the time. Having knowledge in the JAVA language is beneficial...

Words: 515 - Pages: 3

Free Essay

Errors in Programming

...can occur in a program but can be handled in a way that allows the program to continue operation.(Editorial Board, 2014) Dealing with errors in a well-defined way allows programmers to write code to handle errors. This is exception handling. There are pros and cons for using error and exception handling. Exception handling enables normal code to be written and to deal with the exceptional cases code elsewhere. It also provides the means to separate the details of what to do when something out of the ordinary happens from the main logic of a program. A second advantage of exceptions is the ability to propagate error reporting up the call stack of methods which allows grouping and differentiating error type objects. In traditional programming, error detection, reporting, and handling often leads to confusing code. This presents disadvantages because you lose compile time support, the calling method must take care is testing all possible return values, and the code blends leading to cluttering. These errors can only be corrected by fixing the program. The best programs of this type forestall errors if possible, recover from them when they occur without terminating the application, or (if all else fail) gracefully terminate an...

Words: 401 - Pages: 2

Free Essay

Programming Languages

...Assignment 1: Exploring Programming Languages 1970’s Pascal- created by Nicklaus Wirth Designed in 1968-1969 and published in 1970 Intended to teach students structured programming. Used to introduce as undergraduate courses. The first compiler was designed in Zurich for the CDC 600 mainframe computer. Small Talk- Created by Alan Kay, Dan Ingalls, Adele Goldberg Appeared/created in 1972 Was designed to underpin the new world of computing by the human computer symbiosis. For educational use. Influenced by Logo and Sketchpad. Scheme- Created in 1975 Designed Guy L. Steele and Gerald Jay Sussman Was influenced by Lisp, ALGOL, and MDL. Designed to choose lexical scope and was the first to require implementations to perform tail call optimization which gives stronger support for functioning programming. Once was one of the first to support first class continuations. SQL- Created in 1974 Designed by Donald D. Chamberlin and Raymond F. Boyce Influenced by Data log. Designed to manipulate and retrieve data stored in IBM’s original quasi-relational database management system. ML - Created by Robin Milner & others at university of Edinburgh Created in 1973 Motivated by or inspired by ISWIM ...

Words: 1049 - Pages: 5

Free Essay

Modular Programming

...Introducing Algorithms Dedric D. Owens PRG/211 – Algorithms and Logic for Computer Programming October 28, 2013 John Rogers Describe the Top-Down Approach to Algorithm Writing When developing a program, the top-down approach is more than not the preferred method. This is driven by what the program actually does; basically the function of the program. According to Penn State Lehigh Valley, “top-down design or stepwise refinement is an approach to designing an algorithm” and, there are four steps in this top-down design. These steps are as follows: You have to “understand the problem by thoroughly analyzing it.” Then, “formulate the algorithm by determining and writing the main tasks to be carried out as a sequence of general steps”. The third step is to “fill in more details by determining the sub-tasks, if any, for each main task. Lastly, “repeat step third step until you arrive at a precise algorithm expressed in terms of basic executable instructions.” How is pseudo-code used to assist in writing an algorithm? Pseudo-code is defined as an outline of a program written in a form that can easily be converted into real programming statements. It is sometimes confused with an algorithm when developing a program. In reviewing Prelude to Programming: Concepts and Design, Fifth Edition, (para. 2.1, pg 72 an algorithm is “a step by step method for solving a problem or doing a task.” Pseudo-code uses short and easy to understand phrases in plain...

Words: 602 - Pages: 3

Premium Essay

Programming Ch3

... | | | 4. In a structured program, any structure can be nested within another structure.   | a.  | True |   | b.  | False | | | | 5. A structured program must contain a sequence, selection, and loop structure.   | a.  | True |   | b.  | False | | | | 6. Because you may stack and nest structures while retaining the overall structure, it might be difficult to determine whether a flowchart as a whole is structured.   | a.  | True |   | b.  | False | | | | 7. As a general rule, an eof question should always come immediately after an input statement because the end-of-file condition will be detected at input.   | a.  | True |   | b.  | False | | | | 8. Structured programming is sometimes called goto-less programming.   | a.  | True |   | b.  | False | | | | 9. No matter how complicated it is, any set of steps can always be reduced to combinations of the two basic structures of sequence and loop.   | a.  | True |   | b.  | False | | | | 10. The case structure is a variation of the sequence structure and the do loop is a variation of the while loop.   | a.  | True |   | b.  | False | | | | 11. Programs that use _____ code logic are unstructured programs that do not follow the rules of structured logic.   | a.  | case | b.  | loop |   | c.  | spaghetti | d.  | nested | | | | 12. With a(n) ____, you perform an action or task, and then you perform the next action, in order.   | a.  |...

Words: 1062 - Pages: 5

Free Essay

Programming Lenguages

...ro1970’s Pascal is an influential imperative and procedural programming language, designed in 1968–1969 and published in 1970 by Niklaus Wirth as a small and efficient language intended to encourage good programming practices using structured programming and data structuring. A derivative known as Object Pascal designed for object-oriented programming was developed in 1985. ------------------------------- C is a general-purpose programming language initially developed by Dennis Ritchie between 1969 and 1973 at AT&T Bell Labs. Like most imperative languages in the ALGOL tradition, C has facilities for structured programming and allows lexical variable scope and recursion, while a static type system prevents many unintended operations. Its design provides constructs that map efficiently to typical machine instructions, and therefore it has found lasting use in applications that had formerly been coded in assembly language, most notably system software like the Unix computer operating system. ----------------------------------- Prolog is a general purpose logic programming language associated with artificial intelligence and computational linguistics. Prolog has its roots in first-order logic, a formal logic, and unlike many other programming languages, Prolog is declarative: the program logic is expressed in terms of relations, represented as facts and rules. A computation is initiated by running a query over these relations. The language was first conceived by a...

Words: 2012 - Pages: 9