P 6.3) import java.util.scanner;
|
|
- Whitney Greer
- 5 years ago
- Views:
Transcription
1 P 6.3) import java.util.scanner; public class CurrencyConverter public static void main (String[] args) Scanner in = new Scanner(System.in); System.out.print("How many euros is one dollar: "); double rate = in.nextdouble(); boolean done = false; while (!done) System.out.print("Dollar value (Q to quit): "); String input = in.next(); if (input.equalsignorecase("q")) done = true; else double amount = Double.parseDouble(input); double exchange = amount * rate; System.out.printf("%.2f dollar = %.2f euro\n", amount, exchange); //System.out.println(amount + " dollor = " + exchange + " euro"); P 6.4) below you can find the tester class for this question. The main cannonball class is really easy to implement. So you need to do that your self. public static void main(string[] args) Scanner in = new Scanner(System.in); System.out.print("Enter the initial velocity: "); double ivel = in.nextdouble(); final double G = 9.81; double deltat = 0.01; double t = 0; double exactpos = 0; int steps = 0; Cannonball cb = new Cannonball(ivel); do cb.move(deltat); t = t + deltat; steps++; exactpos = -0.5 * G * t * t + ivel * t;
2 if (steps % 100 == 0) System.out.println("Simulation position: " + cb.getposition() + " Velocity: " + cb.getvelocity()); System.out.println("The exact formula position is: " + exactpos); while (exactpos > 0); P 6.5) This question is really easy and just for a hint you can use the constructor below: public PowerGenerator(int afactor) currentpower = 1; factor = afactor; P 6.11) public double nextguess() xold = xnew; if (count == 0) // first time xnew = 1; else xnew = xold * (1-1.0 / n) + a / (n * Math.pow(xOld, n - 1)); count++; return xnew;. public boolean hasmoreguesses() return count <= 2 Math.abs(xNew - xold) > epsilon; P 6.15) this question requires 4 classes. The full solution came below. /** This class tests the Drunkard and Grid classes. */ public class DrunkardViewer public static void main(string[] args) JFrame frame = new JFrame(); frame.setsize(270, 300); frame.settitle("drunkardviewer");
3 frame.setdefaultcloseoperation(jframe.exit_on_close); DrunkardComponent component = new DrunkardComponent(); frame.add(component); frame.setvisible(true);.. public class Grid private static final int RADIUS = 3; private int size; private int nsquares; public Grid(int asize, int ansquares) size = asize; nsquares = ansquares; public void draw(graphics2d g2) // draw the x-direction of the grid double x; for (x = 0; x <= nsquares; x++) Line2D.Double l = new Line2D.Double(x * size, 0, x * size, nsquares * size); g2.draw(l); // draw the y-direction of the grid double y; for (y = 0; y <= nsquares; y++) Line2D.Double l = new Line2D.Double(0, y * size, nsquares * size, y * size); g2.draw(l); public class DrunkardComponent extends JComponent public void paintcomponent(graphics g) Graphics2D g2 = (Graphics2D) g; final int NSQUARES = 20; final int RADIUS = 3;
4 final int MAX_MOVES = 100; int size = Math.min(getWidth(), getheight()) / NSQUARES; Grid mygrid = new Grid(size, NSQUARES); mygrid.draw(g2); int x = NSQUARES / 2; int y = NSQUARES / 2; Drunkard d = new Drunkard(x, y); for (int i = 1; i <= MAX_MOVES; i++) d.move(); x = d.getrow(); y = d.getcolumn(); Ellipse2D.Double e = new Ellipse2D.Double(x * size - RADIUS, y * size - RADIUS, 2 * RADIUS, 2 * RADIUS); g2.draw(e);. /** This class provides methods to simulate the movement of a drunkard. */ public class Drunkard private static final int UP = 0; private static final int DOWN = 1; private static final int LEFT = 2; private static final int RIGHT = 3; private int x; private int y; private Random generator; public Drunkard(int anx, int ay) x = anx; y = ay; generator = new Random(); public void move() int move = generator.nextint(4); if (move == UP) y--; else if (move == DOWN) y++;
5 else if (move == LEFT) x--; else if (move == RIGHT) x++; public int getrow() return x; public int getcolumn() return y;
Sample Solution A10 R6.2 R6.3 R6.5. for (i = 10; i >= 0; i++)... never ends. for (i = -10; i <= 10; i = i + 3)... 6 times
Sample Solution A10 R6.2 0000000000 0123456789 0246802468 0369258147 0482604826 0505050505 0628406284 0741852963 0864208642 0987654321 R6.3 for (i = 10; i >= 0; i++)... never ends for (i = -10; i
More informationSubmit your solution to the Desire2Learn drop box. You may submit as many versions as you like the last one will be graded.
CS46A Exam 2 Exam Rules You may use any books, notes, files, web sites of your choice, except as noted below. It is a good idea to compile and run your programs if you have the time to do it. You may NOT
More informationProgramming Graphics (P1 2006/2007)
Programming Graphics (P1 2006/2007) Fernando Brito e Abreu (fba@di.fct.unl.pt) Universidade Nova de Lisboa (http://www.unl.pt) QUASAR Research Group (http://ctp.di.fct.unl.pt/quasar) Chapter Goals To be
More informationCPS109 Lab 7. Source: Big Java, Chapter 7 Preparation: read Chapter 7 and the lecture notes for this week.
1 CPS109 Lab 7 Source: Big Java, Chapter 7 Preparation: read Chapter 7 and the lecture notes for this week. Objectives: 1. To practice using one- and two-dimensional arrays 2. To practice using partially
More informationChapter Goals. Chapter 5 - Iteration. Calculating the Growth of an Investment
Chapter Goals To be able to program loops with the while and for statements To avoid infinite loops and off-by-one errors To be able to use common loop algorithms To understand nested loops To implement
More information2/9/2015. Chapter 10 Testing and Debugging UNIT TESTS
Chapter 10 Testing and Debugging The Plan For Today Ch.9 Assignment Chapter 10 10.1: Unit Tests 10.2: Providing Test Input 10.3: Test Case Evaluation Ch9/Ch10 Work Time UNIT TESTS The single most important
More informationMidterm Examination (MTA)
M105: Introduction to Programming with Java Midterm Examination (MTA) Spring 2013 / 2014 Question One: [6 marks] Choose the correct answer and write it on the external answer booklet. 1. Compilers and
More informationclass BankFilter implements Filter { public boolean accept(object x) { BankAccount ba = (BankAccount) x; return ba.getbalance() > 1000; } }
9.12) public interface Filter boolean accept(object x); Describes any class whose objects can measure other objects. public interface Measurer double measure(object anobject); This program tests the use
More informationLab Exercise 1. Objectives: Part 1. Introduction
Objectives: king Saud University College of Computer &Information Science CSC111 Lab Object II All Sections - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
More informationIteration Advanced Programming
Iteration Advanced Programming ICOM 4015 Lecture 6 Reading: Java Concepts Chapter 7 Chapter Goals To be able to program loops with the while, for, and do statements To avoid infinite loops and off-by-one
More informationICOM 4015: Advanced Programming
ICOM 4015: Advanced Programming Lecture 3 Reading: Chapter Three: Implementing Classes Copyright 2009 by John Wiley & Sons. All rights reserved. Chapter Three - Implementing Classes Chapter Goals To become
More information2/9/2012. Chapter Three: Implementing Classes. Chapter Goals
Chapter Three: Implementing Classes Chapter Goals To become familiar with the process of implementing classes To be able to implement simple methods To understand the purpose and use of constructors To
More information9/2/2011. Chapter Goals
Chapter Goals To become familiar with the process of implementing classes To be able to implement simple methods To understand the purpose and use of constructors To understand how to access instance fields
More informationCP122 Computer Science I. Chapter 2: Using Objects
CP122 Computer Science I Chapter 2: Using Objects Tech News! Cyber Monday: $3.3B https://youtu.be/r4rfcay9fiq Tech News! Cyber Monday: $3.3B https://youtu.be/r4rfcay9fiq Small drone warfare https://cdn1.tnwcdn.com/wpcontent/blogs.dir/1/files/2016/11/ezgif.comoptimize-1-1.mp4
More informationThe JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class
CHAPTER GRAPHICAL USER INTERFACES 10 Slides by Donald W. Smith TechNeTrain.com Final Draft 10/30/11 10.1 Frame Windows Java provides classes to create graphical applications that can run on any major graphical
More informationSample Solution Assignment 5. Question R3.1
Sample Solution Assignment 5 Question R3.1 The interface of a class is the part that the user interacts with, not necessarily knowing how it works. An implementation of is the creation of this interface.
More informationChapter 2 Using Objects
Chapter 2 Using Objects Chapter Goals To learn about variables To understand the concepts of classes and objects To be able to call methods To learn about parameters and return values To be able to browse
More informationWhat two elements are usually present for calculating a total of a series of numbers?
Dec. 12 Running Totals and Sentinel Values What is a running total? What is an accumulator? What is a sentinel? What two elements are usually present for calculating a total of a series of numbers? Running
More informationMethods (Functions) CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington
Methods (Functions) CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1 What Is a Method? A method is a mechanism for allowing a piece of code to be
More information8/23/2011. Chapter Goals
Chapter Goals Chapter Two: Using Objects To learn about variables To understand the concepts of classes and objects To be able to call methods To learn about parameters and return values To implement test
More information2/9/2012. Chapter Two: Using Objects. Chapter Goals
Chapter Two: Using Objects Chapter Goals To learn about variables To understand the concepts of classes and objects To be able to call methods To learn about parameters and return values To implement test
More informationChapter 2 Using Objects. Copyright 2014 by John Wiley & Sons. All rights reserved. 1
Chapter 2 Using Objects Copyright 2014 by John Wiley & Sons. All rights reserved. 1 Chapter Goals To learn about variables To understand the concepts of classes and objects To be able to call methods To
More informationFinal Examination Semester 2 / Year 2010
Southern College Kolej Selatan 南方学院 Final Examination Semester 2 / Year 2010 COURSE : JAVA PROGRAMMING COURSE CODE : PROG1114 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER : LIM PEI GEOK Student
More information! definite loop: A loop that executes a known number of times. " The for loops we have seen so far are definite loops. ! We often use language like
Indefinite loops while loop! indefinite loop: A loop where it is not obvious in advance how many times it will execute.! We often use language like " "Keep looping as long as or while this condition is
More informationChapter 5 Lab Methods
Chapter 5 Lab Methods Lab Objectives Be able to write methods Be able to call methods Be able to write javadoc comments Be able to create HTML documentation using the javadoc utility Introduction Methods
More informationWarm up Exercise. What are the types and values of the following expressions: * (3 + 1) 3 / / 2.0 (int)1.0 / 2
Warm up Exercise What are the types and values of the following expressions: 3.0+4 * (3 + 1) 3 / 2 + 1.0 1.0 / 2.0 (int)1.0 / 2 COMP-202 - Programming Basics 1 Warm up Exercise What are the types and values
More informationwhile (/* array size less than 1*/){ System.out.print("Number of students is invalid. Enter" + "number of students: "); /* read array size again */
import java.util.scanner; public class CourseManager1 { public static void main(string[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter number of students: "); /* read the number
More informationBranching. Chapter 5 11/14/16 & 11/15/16
Branching Chapter 5 11/14/16 & 11/15/16 Chapter Contents Flow of Control The if Statement Compound Statements Basic Comparisons Comparing Primitives Comparing Objects Chapter Contents The if-else Statement
More informationM105: Introduction to Programming with Java Midterm Examination (MTA) Makeup Spring 2013 / 2014
M105: Introduction to Programming with Java Midterm Examination (MTA) Makeup Spring 2013 / 2014 Question One: Choose the correct answer and write it on the external answer booklet. 1. Java is. a. case
More informationCSC 1051 Villanova University. CSC 1051 Data Structures and Algorithms I. Course website:
Repetition CSC 1051 Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website: www.csc.villanova.edu/~map/1051/ Some slides in this
More informationChapter 2 Using Objects. Types. Number Literals. A type defines a set of values and the operations that can be carried out on the values Examples:
Chapter 2 Using Objects Chapter Goals To learn about variables To understand the concepts of classes and objects To be able to call methods To learn about parameters and return values To be able to browse
More informationJava Coding 3. Over & over again!
Java Coding 3 Over & over again! Repetition Java repetition statements while (condition) statement; do statement; while (condition); where for ( init; condition; update) statement; statement is any Java
More informationAP COMPUTER SCIENCE A
AP COMPUTER SCIENCE A CONTROL FLOW Aug 28 2017 Week 2 http://apcs.cold.rocks 1 More operators! not!= not equals to % remainder! Goes ahead of boolean!= is used just like == % is used just like / http://apcs.cold.rocks
More informationLecture 3: Java Graphics & Events
Lecture 3: Java Graphics & Events CS 62 Fall 2017 Kim Bruce & Alexandra Papoutsaki Text Input Scanner class Constructor: myscanner = new Scanner(System.in); can use file instead of System.in new Scanner(new
More informationAhmadu Bello University Department of Mathematics First Semester Examinations June 2014 COSC211: Introduction to Object Oriented Programming I
Ahmadu Bello University Department of Mathematics First Semester Examinations June 2014 COSC211: Introduction to Object Oriented Programming I Attempt Four questions Time: 120 mins 1. Examine the following
More informationLesson 7 Part 2 Flags
Lesson 7 Part 2 Flags A Flag is a boolean variable that signals when some condition exists in a program. When a flag is set to true, it means some condition exists When a flag is set to false, it means
More informationLoops. CSE 114, Computer Science 1 Stony Brook University
Loops CSE 114, Computer Science 1 Stony Brook University http://www.cs.stonybrook.edu/~cse114 1 Motivation Suppose that you need to print a string (e.g., "Welcome to Java!") a user-defined times N: N?
More informationOct Decision Structures cont d
Oct. 29 - Decision Structures cont d Programming Style and the if Statement Even though an if statement usually spans more than one line, it is really one statement. For instance, the following if statements
More informationIntroduction to Computer Science Unit 2. Notes
Introduction to Computer Science Unit 2. Notes Name: Objectives: By the completion of this packet, students should be able to describe the difference between.java and.class files and the JVM. create and
More informationFundamentals of Programming Data Types & Methods
Fundamentals of Programming Data Types & Methods By Budditha Hettige Overview Summary (Previous Lesson) Java Data types Default values Variables Input data from keyboard Display results Methods Operators
More informationThe correct syntax for the expression is ((x <= 10) && (x >= 1)).
R5.2b. Find the errors in the following if statements: if (x = 1) y++; else if (x = 2) y = y + 2; The relational operator equal is not =, the relational operator equal is == R5.4b. Find the errors in the
More informationBuilding Java Programs
Building Java Programs Chapter 5 Lecture 5-4: do/while loops, assertions reading: 5.1, 5.5 1 The do/while loop do/while loop: Performs its test at the end of each repetition. Guarantees that the loop's
More informationWeb-CAT submission URL: CAT.woa/wa/assignments/eclipse
King Saud University College of Computer & Information Science CSC111 Lab10 Arrays II All Sections ------------------------------------------------------------------- Instructions Web-CAT submission URL:
More informationQuestion 1 [20 points]
Question 1 [20 points] Explain following features of Eclipse IDE. Provide a very short example for each. a) Assume a class Student that represents a student of ECE department at UPRM. Give two different
More informationH212 Introduction to Software Systems Honors
Introduction to Software Systems Honors Lecture #19: November 4, 2015 1/14 Third Exam The third, Checkpoint Exam, will be on: Wednesday, November 11, 2:30 to 3:45 pm You will have 3 questions, out of 9,
More informationCSC 1051 Data Structures and Algorithms I
Repetition CSC 1051 Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website: www.csc.villanova.edu/~map/1051/ Some slides in this
More informationWentworth Institute of Technology. Engineering & Technology WIT COMP1000. Simple Control Flow: if-else statements
WIT COMP1000 Simple Control Flow: if-else statements Control Flow Control flow is the order in which program statements are executed So far, all of our programs have been executed straight-through from
More informationH212 Introduction to Software Systems Honors
Introduction to Software Systems Honors Lecture #04: Fall 2015 1/20 Office hours Monday, Wednesday: 10:15 am to 12:00 noon Tuesday, Thursday: 2:00 to 3:45 pm Office: Lindley Hall, Room 401C 2/20 Printing
More informationHeavyweight with platform-specific widgets. AWT applications were limited to commonfunctionality that existed on all platforms.
Java GUI Windows Events Drawing 1 Java GUI Toolkits Toolkit AWT Description Heavyweight with platform-specific widgets. AWT applications were limited to commonfunctionality that existed on all platforms.
More informationCheck out ThreadsIntro project from SVN. Threads and Animation
Check out ThreadsIntro project from SVN Threads and Animation Often we want our program to do multiple (semi) independent tasks at the same time Each thread of execution can be assigned to a different
More information2.2 - Making Decisions
2.2 - Making Decisions So far we have only made programs that execute the statements in order, starting with the statements at the top of the screen and moving down. However, you can write programs that
More informationChapter 2 An Introduction to Objects and Classes. Big Java by Cay Horstmann Copyright 2009 by John Wiley & Sons. All rights reserved.
Chapter 2 An Introduction to Objects and Classes Chapter Goals To learn about variables To understand the concepts of classes and objects To be able to call methods To learn about parameters and return
More informationBuilding Java Programs
Building Java Programs Chapter 5 Lecture 5-4: do/while loops, assertions reading: 5.1, 5.5 1 The do/while loop do/while loop: Performs its test at the end of each repetition. Guarantees that the loop's
More information1.00 Introduction to Computers and Engineering Problem Solving. Quiz 1 March 7, 2003
1.00 Introduction to Computers and Engineering Problem Solving Quiz 1 March 7, 2003 Name: Email Address: TA: Section: You have 90 minutes to complete this exam. For coding questions, you do not need to
More informationObject Oriented Programming. Java-Lecture 6 - Arrays
Object Oriented Programming Java-Lecture 6 - Arrays Arrays Arrays are data structures consisting of related data items of the same type In Java arrays are objects -> they are considered reference types
More informationCAT.woa/wa/assignments/eclipse
King Saud University College of Computer & Information Science CSC111 Lab10 Arrays II All Sections ------------------------------------------------------------------- Instructions Web-CAT submission URL:
More informationCSIS 10A Assignment 9 Solutions
CSIS 10A Assignment 9 Solutions Read: Chapter 9 Choose and complete any 10 points from the problems below, which are all included in the download file on the website. Use BlueJ to complete the assignment,
More informationWentworth Institute of Technology. Engineering & Technology WIT COMP1000. Methods
WIT COMP1000 Methods Methods Programs can be logically broken down into a set of tasks Example from horoscope assignment:» Get input (month, day) from user» Determine astrological sign based on inputs
More informationSection 002 Spring CS 170 Exam 1. Name (print): Instructions:
CS 170 Exam 1 Section 002 Spring 2015 Name (print): Instructions: Keep your eyes on your own paper and do your best to prevent anyone else from seeing your work. Do NOT communicate with anyone other than
More informationOverview. Lecture 7: Inheritance and GUIs. Inheritance. Example 9/30/2008
Overview Lecture 7: Inheritance and GUIs Written by: Daniel Dalevi Inheritance Subclasses and superclasses Java keywords Interfaces and inheritance The JComponent class Casting The cosmic superclass Object
More informationITERATION WEEK 4: EXMAPLES IN CLASS
Monday Section 2 import java.util.scanner; public class W4MSection2 { ITERATION WEEK 4: EXMAPLES IN CLASS public static void main(string[] args) { Scanner input1 = new Scanner (System.in); int CircleCenterX
More informationCOMP 202 Java in one week
CONTENTS: Basics of Programming Variables and Assignment Data Types: int, float, (string) Example: Implementing a calculator COMP 202 Java in one week The Java Programming Language A programming language
More informationChapter 2. Elementary Programming
Chapter 2 Elementary Programming 1 Objectives To write Java programs to perform simple calculations To obtain input from the console using the Scanner class To use identifiers to name variables, constants,
More informationProgramming with Java
Programming with Java Data Types & Input Statement Lecture 04 First stage Software Engineering Dep. Saman M. Omer 2017-2018 Objectives q By the end of this lecture you should be able to : ü Know rules
More informationFaculty of Science COMP-202B - Introduction to Computing I (Winter 2009) Midterm Examination
First Name: Last Name: McGill ID: Section: Faculty of Science COMP-202B - Introduction to Computing I (Winter 2009) Midterm Examination Monday, March 9, 2009 Examiners: Mathieu Petitpas [Section 1] 18:30
More informationA token is a sequence of characters not including any whitespace.
Scanner A Scanner object reads from an input source (keyboard, file, String, etc) next() returns the next token as a String nextint() returns the next token as an int nextdouble() returns the next token
More informationCOMP-202B - Introduction to Computing I (Winter 2011) - All Sections Example Questions for In-Class Quiz
COMP-202B - Introduction to Computing I (Winter 2011) - All Sections Example Questions for In-Class Quiz The in-class quiz is intended to give you a taste of the midterm, give you some early feedback about
More informationFinal Examination Semester 2 / Year 2012
Final Examination Semester 2 / Year 2012 COURSE : JAVA PROGRAMMING COURSE CODE : PROG1114 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER : LIM PEI GEOK Student s ID : Batch No. : Notes to candidates:
More informationCOMP 202. Java in one week
COMP 202 CONTENTS: Basics of Programming Variables and Assignment Data Types: int, float, (string) Example: Implementing a calculator Java in one week The Java Programming Language A programming language
More informationBoolean Expressions. So, for example, here are the results of several simple Boolean expressions:
Boolean Expressions Now we have the ability to read in some information, calculate some formulas and display the information to the user in a nice format. However, the real power of computer programs lies
More information6.092 Introduction to Software Engineering in Java January (IAP) 2009
MIT OpenCourseWare http://ocw.mit.edu 6.092 Introduction to Software Engineering in Java January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.
More informationCS212 Midterm. 1. Read the following code fragments and answer the questions.
CS1 Midterm 1. Read the following code fragments and answer the questions. (a) public void displayabsx(int x) { if (x > 0) { System.out.println(x); return; else { System.out.println(-x); return; System.out.println("Done");
More informationGive one example where you might wish to use a three dimensional array
CS 110: INTRODUCTION TO COMPUTER SCIENCE SAMPLE TEST 3 TIME ALLOWED: 60 MINUTES Student s Name: MAXIMUM MARK 100 NOTE: Unless otherwise stated, the questions are with reference to the Java Programming
More informationCMPS 11 Introduction to Programming Midterm 1 Review Problems
CMPS 11 Introduction to Programming Midterm 1 Review Problems Note: The necessary material for some of these problems may not have been covered by end of class on Monday, the lecture before the exam. If
More informationFaculty of Science Midterm. COMP-202B - Introduction to Computing I (Winter 2008)
Student Name: Student Number: Section: Faculty of Science Midterm COMP-202B - Introduction to Computing I (Winter 2008) Friday, March 7, 2008 Examiners: Prof. Jörg Kienzle 18:15 20:15 Mathieu Petitpas
More informationCSC 160 LAB 8-1 DIGITAL PICTURE FRAME. 1. Introduction
CSC 160 LAB 8-1 DIGITAL PICTURE FRAME PROFESSOR GODFREY MUGANDA DEPARTMENT OF COMPUTER SCIENCE 1. Introduction Download and unzip the images folder from the course website. The folder contains 28 images
More informationFaculty of Science COMP-202A - Introduction to Computing I (Fall 2008) Midterm Examination
First Name: Last Name: McGill ID: Section: Faculty of Science COMP-202A - Introduction to Computing I (Fall 2008) Midterm Examination Tuesday, November 4, 2008 Examiners: Mathieu Petitpas [Section 1] 18:30
More informationFinal Examination Semester 2 / Year 2011
Southern College Kolej Selatan 南方学院 Final Examination Semester 2 / Year 2011 COURSE COURSE CODE TIME DEPARTMENT LECTURER : JAVA PROGRAMMING : PROG1114 : 2 1/2 HOURS : COMPUTER SCIENCE : LIM PEI GEOK Student
More informationTopic 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
More informationExceptions Handeling
Exceptions Handeling Dr. Ahmed ElShafee Dr. Ahmed ElShafee, Fundamentals of Programming II, ١ Agenda 1. * 2. * 3. * ٢ Dr. Ahmed ElShafee, Fundamentals of Programming II, Introduction During the execution
More informationCSC 231 DYNAMIC PROGRAMMING HOMEWORK Find the optimal order, and its optimal cost, for evaluating the products A 1 A 2 A 3 A 4
CSC 231 DYNAMIC PROGRAMMING HOMEWORK 10-1 PROFESSOR GODFREY MUGANDA 1. Find the optimal order, and its optimal cost, for evaluating the products where A 1 A 2 A 3 A 4 A 1 is 10 4 A 2 is 4 5 A 3 is 5 20
More informationIntroduction to Computer Science Unit 2. Notes
Introduction to Computer Science Unit 2. Notes Name: Objectives: By the completion of this packet, students should be able to describe the difference between.java and.class files and the JVM. create and
More information1.00/1.001 Introduction to Computers and Engineering Problem Solving Spring Quiz 2
1.00/1.001 Introduction to Computers and Engineering Problem Solving Spring 2010 - Quiz 2 Name: MIT Email: TA: Section: You have 80 minutes to complete this exam. For coding questions, you do not need
More informationIt is a constructor and is called using the new statement, for example, MyStuff m = new MyStuff();
COSC 117 Exam 3 Key Fall 2012 Part 1: Definitions & Short Answer (3 Points Each) 1. A method in a class that has no return type and the same name as the class is called what? How is this type of method
More informationQuestion 1 [20 points]
Question 1 [20 points] a) Write the following mathematical expression in Java. c=math.sqrt(math.pow(a,2)+math.pow(b,2)- 2*a*b*Math.cos(gamma)); b) Write the following Java expression in mathematical notation.
More informationObject-Oriented Programming Design. Topic : Graphics Programming GUI Part I
Electrical and Computer Engineering Object-Oriented Topic : Graphics GUI Part I Maj Joel Young Joel.Young@afit.edu 15-Sep-03 Maj Joel Young A Brief History Lesson AWT Abstract Window Toolkit Implemented
More informationQuestion Topic: Single Class. Question 1:
Question Topic: Single Class Question 1: a. Design a class which draws a rectangle made of asterixes to the console area. The class must contain at least one method which determines the side s lengths
More informationCSC 1051 Data Structures and Algorithms I
Repetition CSC 1051 Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website: www.csc.villanova.edu/~map/1051/ Some slides in this
More informationCCHS Math Recursion Worksheets M Heinen CS-A 12/5/2013. Recursion Worksheets Plus Page 1 of 6
CS-A // arraysol[][] = r; import java.util.scanner; public class RecursionApp { static int r; // return value static int[][] arraysol = new int[][7]; // create a solution array public static void main(string[]
More informationNew York University Introduction to Computer Science Exam Sample Problems 2013 Andrew I. Case. Instructions:
Name: New York University Introduction to Computer Science Exam Sample Problems 2013 Andrew I. Case Instructions: KEEP TEST BOOKLET CLOSED UNTIL YOU ARE INSTRUCTED TO BEGIN. This exam is double sided (front
More informationCSE 114 Computer Science I
CSE 114 Computer Science I Iteration Cape Breton, Nova Scotia What is Iteration? Repeating a set of instructions a specified number of times or until a specific result is achieved How do we repeat steps?
More informationCourse overview: Introduction to programming concepts
Course overview: Introduction to programming concepts What is a program? The Java programming language First steps in programming Program statements and data Designing programs. This part will give an
More informationBuilding a Java First-Person Shooter
Building a Java First-Person Shooter Episode 3 Arrays [Last update: 4/30/2017] Objectives This episode discusses the use of arrays in Java and the introduction of a class that will handle what gets rendered/drawn
More informationThe for Loop, Accumulator Variables, Seninel Values, and The Random Class. CS0007: Introduction to Computer Programming
The for Loop, Accumulator Variables, Seninel Values, and The Random Class CS0007: Introduction to Computer Programming Review General Form of a switch statement: switch (SwitchExpression) { case CaseExpression1:
More informationBig Java. Fifth Edition. Chapter 3 Fundamental Data Types. Cay Horstmann
Big Java Fifth Edition Cay Horstmann Chapter 3 Fundamental Data Types Chapter Goals To understand integer and floating-point numbers To recognize the limitations of the numeric types To become aware of
More informationExercise 0.1 (Review from lectures no submission required)
CSCI 2110- Data Structures and Algorithms Laboratory No. 1 Week of September 10, 2018 Due: Saturday, September 15, 2018, 11.55 PM (five minutes to midnight) Review of Object-Oriented Programming Concepts
More informationComputer Programming, I. Laboratory Manual. Experiment #2. Elementary Programming
Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Experiment #2
More informationSoftware and Programming 1
Software and Programming 1 Week 9 Lab - Use of Classes and Inheritance 8th March 2018 SP1-Lab9-2018.ppt Tobi Brodie (Tobi@dcs.bbk.ac.uk) 1 Lab 9: Objectives Exercise 1 Student & StudentTest classes 1.
More informationCS 101 Spring 2007 Midterm 2 Name: ID:
You only need to write your name and e-mail ID on the first page. This exam is CLOSED text book, closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts, so be sure
More informationExample Program. public class ComputeArea {
COMMENTS While most people think of computer programs as a tool for telling computers what to do, programs are actually much more than that. Computer programs are written in human readable language for
More information