# Software and Programming 1

Save this PDF as:

Size: px
Start display at page:

## Transcription

1 Software and Programming 1 Lab 3: Strings & Conditional Statements 20 January 2016 SP1-Lab3.ppt Tobi Brodie 1

2 Lab Objectives This session we are concentrating on Strings and conditional statements. Exercise 1*: ReverseWord (String). The exercise involves using a for loop to manipulate the value of a String variable. In order to complete this exercise you will be using both String and char data types. Exercise 2: RomanNumer (Conditional Statement). This more complex exercise involves the use of the IF/ELSE IF/ELSE conditional. Exercise 3*: RomanDigit (Method). This exercise requires you to rewrite the RomanNumber program using a method that can be called with arguments. *Exercises 1 & 3 are both checked exercises and you are required to complete them and show the working programs when requested. We will not be checking this week s exercise 3 until week six, but you should attempt to complete it today. 2

3 Exercise 1 Reverse Word Write a program that reads a word and prints the word in reverse (see JFE, 2 nd Ed, exercise P4.9 on p. 189). For example if the user provides the input "Harry", the program prints yrrah import java.util.scanner; public class ReverseWord public static void main(string[] args) // Use the Scanner java utility package to read a word // from the keyboard using the method in.next() // Use a for loop to print the word in reverse 3

4 Exercise 2 Roman Numerals Write a program that converts a positive integer into the Roman number system. The Roman number system has digits I (1), V (5), X (10), L (50), C(100), D(500) and M(1000). Numbers up to 3999 are formed according to the following rules: a) As in the decimal system, the thousands, hundreds, tens and ones are expressed separately. b) The numbers 1 to 9 are expressed as: 1 I 4 IV 2 II 5 V 3 III 6 VI 7 VII 8 VIII 9 IX (An I preceding a V or X is subtracted from the value, and there cannot be more than three I s in a row.) c) Tens and hundreds are done the same way, except that the letters X, L, C, and C, D, M are used instead of I, V, X, respectively. Your program should take an input, such as 1978, and convert it to Roman numerals, MCMLXXVIII (JFE, 2 nd Ed, exercise P3.26 on p. 130.) 4

5 Hints: Exercise 2 (3): Conversion Algorithm 1. Use the following method to convert a positive number into Roman numerals and return it as a string. public static String convert(int n) 2. Inside the method, write an if statement to check for numbers in the range 0 to If the above is valid, apply the following rules: i. Use if and for statements to convert numbers in the range 1 and 9 into Roman numerals. Note: an I preceding a V or X is subtracted from the value, and there cannot be more than three I s in a row. ii. Tens and hundreds are done in the same way, using if and for statements, except that the letters X, L, C and C, D, M are used. 5

6 Exercise 2: Basic structure of Class RomanNumber /** Roman Number system class **/ import java.util.scanner; public class RomanNumber public static void main(string[ ] args) /* write code to take an input and store it in a variable, number */ /* call method convert */ String romanstr = convert(number); // Output value returned from the convert method. 6

7 Exercise 2: Basic structure of Class RomanNumber (2) public static String convert(int n) // declare a String to store result String roman = ""; // write code to convert the number, n, into Roman numerals if ((n >= 1) && (n <= 3999)) /* Step 1 Determine how many thousands, hundreds, tens and units are in the given number, n */ int thousand = (n / 1000); int hundred = (n % 1000) / 100; int ten = to do ; // write formula to find the tens int unit = to do ; // write formula to find the units // see next slide 7

8 Exercise 2: Basic structure of Class RomanNumber (3) // continuation of the method convert() /* Step 2 Convert the thousands into a Roman numeral and append it to the string roman*/ /* Step 3 Convert the hundreds and append it */ /* Step 4 Convert the tens and append it */ /* Step 5 Convert the units and append it */ else roman = "Number can t be converted "; // return value stored in variable roman return roman; // end of method convert() // end of class RomanNumber 8

9 Exercise 2: Step 2 convert the thousands into a Roman numeral if (thousand > = 1) if (thousand == 1) roman += "M"; else if (thousand == 2) roman += "MM"; else roman += "MMM"; 9

10 Exercise 2: Step 3 convert the hundreds into a Roman numeral if (hundred >= 1) if (hundred == 1) roman += "C"; else if (hundred == 2) roman += "CC"; else if (hundred == 3) roman += "CCC"; else if (hundred == 4) roman += "CD"; else if (hundred == 5) roman += "D"; else if (hundred == 6) roman += "DC"; else if (hundred == 7) roman += "DCC"; else if (hundred == 8) roman += "DCCC"; else roman += "CM"; 10

11 Exercise 2: Steps 4 & 5 convert the tens and units into a Roman numerals The code required for steps 4 and 5 is similar to that used to convert the hundreds into a Roman numeral (step 3). In step 4 you will be replacing the letters C and D with the letters X (10) and L (50) respectively. Step 5 follows the same format, but replacing with the numerals for units: I (1) and V (5). 11

12 Exercise 3 Rewrite the Roman number system program by implementing and using the following method: public static String romandigit(int n, String one, String five, String ten) The above method translates one decimal digit, using the strings specified for the one, five and ten values. You would call the method as follows: romanunits = romandigit(n % 10, "I", "V", "X"); n = n / 10; romantens = romandigit(n % 10, "X", "L", "C"); 12

### Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

Translation Translating to Java Introduction to Computer Programming The job of a programmer is to translate a problem description into a computer language. You need to be able to convert a problem description

### System.out.println("\nEnter Product Number 1-5 (0 to stop and view summary) :

Benjamin Michael Java Homework 3 10/31/2012 1) Sales.java Code // Sales.java // Program calculates sales, based on an input of product // number and quantity sold import java.util.scanner; public class

### CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

Oct 4, 2013, p 1 Name: CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 1. (max 18) 4. (max 16) 2. (max 12) 5. (max 12) 3. (max 24) 6. (max 18) Total: (max 100)

### COUNTING LOOPS AND ACCUMULATORS

COUNTING LOOPS AND ACCUMULATORS Two very important looping idioms are counting loops and accumulators. A counting loop uses a variable, called the loop control variable, to keep count of how many cycles

### Introduction to Java

Introduction to Java The HelloWorld program Primitive data types Assignment and arithmetic operations User input Conditional statements Looping Arrays CSA0011 Matthew Xuereb 2008 1 Java Overview A high

### Sample CSE8A midterm Multiple Choice (circle one)

Sample midterm Multiple Choice (circle one) (2 pts) Evaluate the following Boolean expressions and indicate whether short-circuiting happened during evaluation: Assume variables with the following names

### Chapter 2 Introduction to Java programming

Chapter 2 Introduction to Java programming 1 Keywords boolean if interface class true char else package volatile false byte final switch while throws float private case return native void protected break

### Basics of Java Programming Input and the Scanner class

Basics of Java Programming Input and the Scanner class CSC 1051 Algorithms and Data Structures I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website: www.csc.villanova.edu/~map/1051/

### Scanner sc = new Scanner(System.in); // scanner for the keyboard. Scanner sc = new Scanner(System.in); // scanner for the keyboard

INPUT & OUTPUT I/O Example Using keyboard input for characters import java.util.scanner; class Echo{ public static void main (String[] args) { Scanner sc = new Scanner(System.in); // scanner for the keyboard

### Java How to Program, 9/e

Java How to Program, 9/e Education, Inc. All Rights Reserved. 1 Any computing problem can be solved by executing a series of actions in a specific order. An algorithm is a procedure for solving a problem

### AP Computer Science Static Methods, Strings, User Input

AP Computer Science Static Methods, Strings, User Input Static Methods The Math class contains a special type of methods, called static methods. A static method DOES NOT operate on an object. This is because

### AP Computer Science Java Mr. Clausen Program 9A, 9B

AP Computer Science Java Mr. Clausen Program 9A, 9B PROGRAM 9A I m_sort_of_searching (20 points now, 60 points when all parts are finished) The purpose of this project is to set up a program that will

### Introduction to Programming

Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems sjmaybank@dcs.bbk.ac.uk Spring 2015 Week 2b: Review of Week 1, Variables 16 January 2015 Birkbeck

### Sources: On the Web: Slides will be available on:

C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,

### Chulalongkorn University International School of Engineering Department of Computer Engineering 2140105 Computer Programming Lab.

Chulalongkorn University Name International School of Engineering Student ID Department of Computer Engineering Station No. 2140105 Computer Programming Lab. Date Lab 2 Using Java API documents, command

### JAVA ARRAY EXAMPLE PDF

JAVA ARRAY EXAMPLE PDF Created By: Umar Farooque Khan 1 Java array example for interview pdf Program No: 01 Print Java Array Example using for loop package ptutorial; public class PrintArray { public static

CS 259: Data Structures with Java Hello World with the IntelliJ IDE Instructor: Joel Castellanos e-mail: joel.unm.edu Web: http://cs.unm.edu/~joel/ Office: Farris Engineering Center 319 8/19/2015 Install

### J a v a Quiz (Unit 3, Test 0 Practice)

Computer Science S-111a: Intensive Introduction to Computer Science Using Java Handout #11 Your Name Teaching Fellow J a v a Quiz (Unit 3, Test 0 Practice) Multiple-choice questions are worth 2 points

### Example of a Java program

Example of a Java program class SomeNumbers static int square (int x) return x*x; public static void main (String[] args) int n=20; if (args.length > 0) // change default n = Integer.parseInt(args[0]);

### Object-Oriented Programming in Java

CSCI/CMPE 3326 Object-Oriented Programming in Java Class, object, member field and method, final constant, format specifier, file I/O Dongchul Kim Department of Computer Science University of Texas Rio

### Java Basics: Data Types, Variables, and Loops

Java Basics: Data Types, Variables, and Loops If debugging is the process of removing software bugs, then programming must be the process of putting them in. - Edsger Dijkstra Plan for the Day Variables

### Topic 11 Scanner object, conditional execution

Topic 11 Scanner object, conditional execution "There are only two kinds of programming languages: those people always [complain] about and those nobody uses." Bjarne Stroustroup, creator of C++ Copyright

### MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Exam Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) The JDK command to compile a class in the file Test.java is A) java Test.java B) java

### Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C

Basic Java Constructs and Data Types Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C 1 Contents Hello World Program Statements Explained Java Program Structure in

### Schneps, Leila; Colmez, Coralie. Math on Trial : How Numbers Get Used and Abused in the Courtroom. New York, NY, USA: Basic Books, 2013. p i.

New York, NY, USA: Basic Books, 2013. p i. http://site.ebrary.com/lib/mcgill/doc?id=10665296&ppg=2 New York, NY, USA: Basic Books, 2013. p ii. http://site.ebrary.com/lib/mcgill/doc?id=10665296&ppg=3 New

### IRA EXAMPLES. This topic has two examples showing the calculation of the future value an IRA (Individual Retirement Account).

IRA EXAMPLES This topic has two examples showing the calculation of the future value an IRA (Individual Retirement Account). Definite Counting Loop Example IRA After x Years This first example illustrates

### Roman Numeral Table. Basic Calculations Review

Basic Calculations Review I. Okay. It has been a long time since we have had to even THINK about Roman numerals vs. Arabic numerals, right? So just to refresh, a Roman numeral looks like this XVI but an

### Part I:( Time: 90 minutes, 30 Points)

Qassim University Deanship of Educational Services Preparatory Year Program- Computer Science Unit Final Exam - 1434/1435 CSC111 Time: 2 Hours + 10 Minutes 1 MG Student name: Select the correct choice:

### CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals 1 Recall From Last Time: Java Program import java.util.scanner; public class EggBasket { public static void main(string[]

### Programming Languages CIS 443

Course Objectives Programming Languages CIS 443 0.1 Lexical analysis Syntax Semantics Functional programming Variable lifetime and scoping Parameter passing Object-oriented programming Continuations Exception

### Object Oriented Software Design

Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 28, 2010 G. Lipari (Scuola Superiore Sant Anna) Introduction

### The following program is aiming to extract from a simple text file an analysis of the content such as:

Text Analyser Aim The following program is aiming to extract from a simple text file an analysis of the content such as: Number of printable characters Number of white spaces Number of vowels Number of

### Object Oriented Software Design

Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa September 14, 2011 G. Lipari (Scuola Superiore Sant Anna) Introduction

### Homework/Program #5 Solutions

Homework/Program #5 Solutions Problem #1 (20 points) Using the standard Java Scanner class. Look at http://natch3z.blogspot.com/2008/11/read-text-file-using-javautilscanner.html as an exampleof using the

### CSE 1223: Introduction to Computer Programming in Java Chapter 7 File I/O

CSE 1223: Introduction to Computer Programming in Java Chapter 7 File I/O 1 Sending Output to a (Text) File import java.util.scanner; import java.io.*; public class TextFileOutputDemo1 public static void

### Part I. Multiple Choice Questions (2 points each):

Part I. Multiple Choice Questions (2 points each): 1. Which of the following is NOT a key component of object oriented programming? (a) Inheritance (b) Encapsulation (c) Polymorphism (d) Parallelism ******

### 6.1. Example: A Tip Calculator 6-1

Chapter 6. Transition to Java Not all programming languages are created equal. Each is designed by its creator to achieve a particular purpose, which can range from highly focused languages designed for

### JDK 1.5 Updates for Introduction to Java Programming with SUN ONE Studio 4

JDK 1.5 Updates for Introduction to Java Programming with SUN ONE Studio 4 NOTE: SUN ONE Studio is almost identical with NetBeans. NetBeans is open source and can be downloaded from www.netbeans.org. I

### MIDTERM 1 REVIEW WRITING CODE POSSIBLE SOLUTION

MIDTERM 1 REVIEW WRITING CODE POSSIBLE SOLUTION 1. Write a loop that computes (No need to write a complete program) 100 1 99 2 98 3 97... 4 3 98 2 99 1 100 Note: this is not the only solution; double sum

### CS170 Lab 11 Abstract Data Types & Objects

CS170 Lab 11 Abstract Data Types & Objects Introduction: Abstract Data Type (ADT) An abstract data type is commonly known as a class of objects An abstract data type in a program is used to represent (the

### WA2099 Introduction to Java using RAD 8.0 EVALUATION ONLY. Student Labs. Web Age Solutions Inc.

WA2099 Introduction to Java using RAD 8.0 Student Labs Web Age Solutions Inc. 1 Table of Contents Lab 1 - The HelloWorld Class...3 Lab 2 - Refining The HelloWorld Class...20 Lab 3 - The Arithmetic Class...25

### Fractions to decimals

Worksheet.4 Fractions and Decimals Section Fractions to decimals The most common method of converting fractions to decimals is to use a calculator. A fraction represents a division so is another way of

### Programming Fundamentals I CS 110, Central Washington University. November 2015

Programming Fundamentals I CS 110, Central Washington University November 2015 Next homework, #4, was due tonight! Lab 6 is due on the 4 th of November Final project description + pseudocode are due 4th

### In this Chapter you ll learn:

Now go, write it before them in a table, and note it in a book. Isaiah 30:8 To go beyond is as wrong as to fall short. Confucius Begin at the beginning, and go on till you come to the end: then stop. Lewis

### D06 PROGRAMMING with JAVA

Cicles Formatius de Grau Superior Desenvolupament d Aplicacions Informàtiques D06 PROGRAMMING with JAVA Ch16 Files and Streams PowerPoint presentation, created by Angel A. Juan - ajuanp(@)gmail.com, for

### An Incomplete C++ Primer. University of Wyoming MA 5310

An Incomplete C++ Primer University of Wyoming MA 5310 Professor Craig C. Douglas http://www.mgnet.org/~douglas/classes/na-sc/notes/c++primer.pdf C++ is a legacy programming language, as is other languages

### Management Information Systems 260 Web Programming Fall 2006 (CRN: 42459)

Management Information Systems 260 Web Programming Fall 2006 (CRN: 42459) Class Time: 6:00 8:05 p.m. (T,Th) Venue: WSL 5 Web Site: www.pbvusd.net/mis260 Instructor Name: Terrell Tucker Office: BDC 127

### AP Computer Science Java Subset

APPENDIX A AP Computer Science Java Subset The AP Java subset is intended to outline the features of Java that may appear on the AP Computer Science A Exam. The AP Java subset is NOT intended as an overall

### COSC 2231 - Programming 1 Week 1 Laboratory Exercises

COSC 2231 - Programming 1 Week 1 Laboratory Exercises Programming 1 Resources/Simple Java Programming Use JCreator to type/edit program source code 1. Write a program which produces the following output

### Section 6 Spring 2013

Print Your Name You may use one page of hand written notes (both sides) and a dictionary. No i-phones, calculators or any other type of non-organic computer. Do not take this exam if you are sick. Once

### CS1020 Data Structures and Algorithms I Lecture Note #1. Introduction to Java

CS1020 Data Structures and Algorithms I Lecture Note #1 Introduction to Java Objectives Java Basic Java features C Java Translate C programs in CS1010 into Java programs 2 References Chapter 1 Section

### First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science

First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca

### Introduction to Java. CS 3: Computer Programming in Java

Introduction to Java CS 3: Computer Programming in Java Objectives Begin with primitive data types Create a main class with helper methods Learn how to call built-in class methods and instance methods

### Arrays in Java. Working with Arrays

Arrays in Java So far we have talked about variables as a storage location for a single value of a particular data type. We can also define a variable in such a way that it can store multiple values. Such

### If-Else and Boolean Expressions

If-Else and Boolean Expressions Decide who will be what role for today's activity. List the names of your team members next to their role. Manager: Spokesperson: Quality Control/Recorder: Process Analyst:

1 2 Introduction to Java Applications 2.2 First Program in Java: Printing a Line of Text 2 Application Executes when you use the java command to launch the Java Virtual Machine (JVM) Sample program Displays

### Chapter 3. Input and output. 3.1 The System class

Chapter 3 Input and output The programs we ve looked at so far just display messages, which doesn t involve a lot of real computation. This chapter will show you how to read input from the keyboard, use

### Using Two-Dimensional Arrays

Using Two-Dimensional Arrays Great news! What used to be the old one-floor Java Motel has just been renovated! The new, five-floor Java Hotel features a free continental breakfast and, at absolutely no

### 1. Writing Simple Classes:

The University of Melbourne Department of Computer Science and Software Engineering 433-254 Software Design Semester 2, 2003 Answers for Lab 2 Week 3 1. Writing Simple Classes: a) In Java systems, there

### More on Objects and Classes

Software and Programming I More on Objects and Classes Roman Kontchakov Birkbeck, University of London Outline Object References Class Variables and Methods Packages Testing a Class Discovering Classes

### Chapter 2: Elements of Java

Chapter 2: Elements of Java Basic components of a Java program Primitive data types Arithmetic expressions Type casting. The String type (introduction) Basic I/O statements Importing packages. 1 Introduction

### C programming: exercise sheet L2-STUE (2011-2012)

C programming: exercise sheet L2-STUE (2011-2012) Algorithms and Flowcharts Exercise 1: comparison Write the flowchart and associated algorithm that compare two numbers a and b. Exercise 2: 2 nd order

### Chapter 2 Elementary Programming

Chapter 2 Elementary Programming 2.1 Introduction You will learn elementary programming using Java primitive data types and related subjects, such as variables, constants, operators, expressions, and input

### You are to simulate the process by making a record of the balls chosen, in the sequence in which they are chosen. Typical output for a run would be:

Lecture 7 Picking Balls From an Urn The problem: An urn has n (n = 10) balls numbered from 0 to 9 A ball is selected at random, its' is number noted, it is set aside, and another ball is selected from

### Scanner. It takes input and splits it into a sequence of tokens. A token is a group of characters which form some unit.

Scanner The Scanner class is intended to be used for input. It takes input and splits it into a sequence of tokens. A token is a group of characters which form some unit. For example, suppose the input

### Computer Programming I

Computer Programming I COP 2210 Syllabus Spring Semester 2012 Instructor: Greg Shaw Office: ECS 313 (Engineering and Computer Science Bldg) Office Hours: Tuesday: 2:50 4:50, 7:45 8:30 Thursday: 2:50 4:50,

### Using Files as Input/Output in Java 5.0 Applications

Using Files as Input/Output in Java 5.0 Applications The goal of this module is to present enough information about files to allow you to write applications in Java that fetch their input from a file instead

### Reading a Text File. Reading and Writing Text Files Exceptions. Testing for more input. Example: Count Words

Reading a Text File Reading and Writing Text Files Exceptions 15-121 Fall 2010 Margaret Reid-Miller A Scanner object can be connected to many input sources: keyboard, file, network, string To read a text

### Comp 248 Introduction to Programming

Comp 248 Introduction to Programming Chapter 2 - Console Input & Output Dr. Aiman Hanna Department of Computer Science & Software Engineering Concordia University, Montreal, Canada These slides has been

### COSC 111: Computer Programming I. Dr. Bowen Hui University of Bri>sh Columbia Okanagan

COSC 111: Computer Programming I Dr. Bowen Hui University of Bri>sh Columbia Okanagan 1 Today Review slides from week 2 Review another example with classes and objects Review classes in A1 2 Discussion

### This activity will guide you to create formulas and use some of the built-in math functions in EXCEL.

Purpose: This activity will guide you to create formulas and use some of the built-in math functions in EXCEL. The three goals of the spreadsheet are: Given a triangle with two out of three angles known,

### JAVA NOTES DATA STRUCTURES AND ALGORITHMS

15 JAVA NOTES DATA STRUCTURES AND ALGORITHMS Terry Marris July 2001 3 LINEAR SEARCH 3.1 LEARNING OUTCOMES By the end of this lesson the student should be able to describe how a linear search algorithm

### Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

Handout 1 CS603 Object-Oriented Programming Fall 15 Page 1 of 11 Handout 1 Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Java

### Introduction to Computer Programming, Spring Term 2014 Practice Assignment 3 Discussion 15.3.2014-20.3.2014

German University in Cairo Media Engineering and Technology Prof. Dr. Slim Abdennadher Dr. Ahmed Gamal Introduction to Computer Programming, Spring Term 2014 Practice Assignment 3 Discussion 15.3.2014-20.3.2014

### GTU Questions. Computer Programming & Utilization. Chief Course Coordinator Prof. Mitul K.Patel. (Head of Department & Assistant Professor)

GTU Questions Computer Programming & Utilization Chief Course Coordinator Prof. Mitul K.Patel (Head of Department & Assistant Professor) Course Coordinator Prof. Vrutti D. Shah (Assistant Professor) Lab

### Introduction to Object-Oriented Programming

Introduction to Object-Oriented Programming Programs and Methods Christopher Simpkins chris.simpkins@gatech.edu CS 1331 (Georgia Tech) Programs and Methods 1 / 8 The Anatomy of a Java Program It is customary

Business Information Management I Texas 130.114 This document describes the correlation between curriculum, supplied by Applied Educational Systems, and the Business Information Management I standard,

### Building Java Programs

Building Java Programs Chapter 4 Lecture 4-1: Scanner; if/else reading: 3.3 3.4, 4.1 Interactive Programs with Scanner reading: 3.3-3.4 1 Interactive programs We have written programs that print console

### LABORATORY MANUAL. CS-4205 Programming and Problem Solving Using C. July 2012 Onwards. Devi Ahilya Vishwavidyalaya. School of Computer Science & IT

LORTORY MNUL CS-4205 Programming and Problem Solving Using C July 202 Onwards Devi hilya Vishwavidyalaya School of Computer Science & IT We make things happen... Producing world class IT Professionals

### Arrays. Introduction. Chapter 7

CH07 p375-436 1/30/07 1:02 PM Page 375 Chapter 7 Arrays Introduction The sequential nature of files severely limits the number of interesting things you can easily do with them.the algorithms we have examined

### MAT 2170: Laboratory 3

MAT 2170: Laboratory 3 Key Concepts The purpose of this lab is to familiarize you with arithmetic expressions in Java. 1. Primitive Data Types int and double 2. Operations involving primitive data types,

### Programmierpraktikum

Programmierpraktikum Claudius Gros, SS2012 Institut für theoretische Physik Goethe-University Frankfurt a.m. 1 of 21 10/16/2012 09:29 AM Java - A First Glance 2 of 21 10/16/2012 09:29 AM programming languages

### C Programming Dr. Hasan Demirel

C How to Program, H. M. Deitel and P. J. Deitel, Prentice Hall, 5 th edition (3 rd edition or above is also OK). Introduction to C Programming Dr. Hasan Demirel Programming Languages There are three types

### B.Sc.(Computer Science) and. B.Sc.(IT) Effective From July 2011

NEW Detailed Syllabus of B.Sc.(Computer Science) and B.Sc.(IT) Effective From July 2011 SEMESTER SYSTEM Scheme & Syllabus for B.Sc. (CS) Pass and Hons. Course Effective from July 2011 and onwards CLASS

### Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013

Masters programmes in Computer Science and Information Systems Object-Oriented Design and Programming Sample module entry test xxth December 2013 This sample paper has more questions than the real paper

### Chapter 2 Basics of Scanning and Conventional Programming in Java

Chapter 2 Basics of Scanning and Conventional Programming in Java In this chapter, we will introduce you to an initial set of Java features, the equivalent of which you should have seen in your CS-1 class;

### Lecture 5: Java Fundamentals III

Lecture 5: Java Fundamentals III School of Science and Technology The University of New England Trimester 2 2015 Lecture 5: Java Fundamentals III - Operators Reading: Finish reading Chapter 2 of the 2nd

### Fundamentals of Programming. Laboratory 5 Methods. General-purpose and user - defined methods

Fundamentals of Programming Laboratory 5 Methods. General-purpose and user - defined methods What is a method? Block of code that receives its own identifier - i.e. can be executed using its name Different

### qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq Introduction to Programming using Java wertyuiopasdfghjklzxcvbnmqwertyui

### Roman Numerals. Symbol Decimal Value I One (1) V Five (5) X Ten (10) L Fifty (50) C Hundred (100) D Five Hundred (500) M Thousand (1000)

Roman Numerals Pre-requisite: Number System, Addition and Subtraction. Target Audience: Standard V to Standard VII. In Syllabus Standard V. Revision Standard VI & VII. Symbol Decimal Value I One (1) V

### Building Java Programs

Building Java Programs Chapter 5 Lecture 5-2: Random Numbers reading: 5.1-5.2 self-check: #8-17 exercises: #3-6, 10, 12 videos: Ch. 5 #1-2 1 The Random class A Random object generates pseudo-random* numbers.

### Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

Introduction to Programming and Algorithms Module 1 CS 146 Sam Houston State University Dr. Tim McGuire Module Objectives To understand: the necessity of programming, differences between hardware and software,

### C Primer. Fall Introduction C vs. Java... 1

CS 33 Intro Computer Systems Doeppner C Primer Fall 2016 Contents 1 Introduction 1 1.1 C vs. Java.......................................... 1 2 Functions 1 2.1 The main() Function....................................

### RARITAN VALLEY COMMUNITY COLLEGE ACADEMIC COURSE OUTLINE. CISY 105 Foundations of Computer Science

I. Basic Course Information RARITAN VALLEY COMMUNITY COLLEGE ACADEMIC COURSE OUTLINE CISY 105 Foundations of Computer Science A. Course Number and Title: CISY-105, Foundations of Computer Science B. New

### LAB4 Making Classes and Objects

LAB4 Making Classes and Objects Objective The main objective of this lab is class creation, how its constructer creation, object creation and instantiation of objects. We will use the definition pane to

### Programming and Data Structures with Java and JUnit. Rick Mercer

Programming and Data Structures with Java and JUnit Rick Mercer ii Chapter Title 1 Program Development 2 Java Fundamentals 3 Objects and JUnit 4 Methods 5 Selection (if- else) 6 Repetition (while and for

### Arrays - Introduction. Declaration of Arrays. Initialisation of Arrays. Creation of Arrays. Arrays, Strings and Collections [1]

Arrays - Introduction Arrays, Strings and Collections [] Rajkumar Buyya Grid Computing and Distributed Systems (GRIDS) Laboratory Dept. of Computer Science and Software Engineering University of Melbourne,

### Chapter 2. println Versus print. Formatting Output withprintf. System.out.println for console output. console output. Console Input and Output

Chapter 2 Console Input and Output System.out.println for console output System.out is an object that is part of the Java language println is a method invoked dby the System.out object that can be used