(First is used here)

Similar documents
C Sc 227 Project 1: Three Main Methods

There are several files including the start of a unit test and the method stubs in MindNumber.java. Here is a preview of what you will do:

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

Introduction to Java Unit 1. Using BlueJ to Write Programs

S8352: Java From the Very Beginning Part I - Exercises

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

Full file at

Introduction to Computer Programming

Midterms Save the Dates!

AP Computer Science Unit 1. Writing Programs Using BlueJ

Section 1: Let s Shake Off the Rust!

Wentworth Institute of Technology. Engineering & Technology WIT COMP1000. Java Basics

Instructions PLEASE READ (notice bold and underlined phrases)

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics

Due Date: Two Program Demonstrations (Testing and Debugging): End of Lab

Eclipse Environment Setup

CMSC 150 INTRODUCTION TO COMPUTING LAB WEEK 3 STANDARD IO FORMATTING OUTPUT SCANNER REDIRECTING

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. A Guide to this Instructor s Manual:

Full file at

Mobile App:IT. Methods & Classes

Object Oriented Programming. Java-Lecture 1

How to make a "hello world" program in Java with Eclipse *

Fundamentals of Programming Session 4

Check out how to use the random number generator (introduced in section 4.11 of the text) to get a number between 1 and 6 to create the simulation.

Open Book Format.docx. Headers and Footers. Microsoft Word Part 3 Office 2016

Laboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information

The NetBeans IDE is a big file --- a minimum of around 30 MB. After you have downloaded the file, simply execute the file to install the software.

2. You are required to enter a password of up to 100 characters. The characters must be lower ASCII, printing characters.

AP Computer Science Unit 1. Writing Programs Using BlueJ

CIS220 In Class/Lab 1: Due Sunday night at midnight. Submit all files through Canvas (25 pts)

Due: 9 February 2017 at 1159pm (2359, Pacific Standard Time)

Lesson 10: Quiz #1 and Getting User Input (W03D2)

Constants. Why Use Constants? main Method Arguments. CS256 Computer Science I Kevin Sahr, PhD. Lecture 25: Miscellaneous

Skill 1: Multiplying Polynomials

At the shell prompt, enter idlde

What did we talk about last time? Examples switch statements

Entry Point of Execution: the main Method. Elementary Programming. Learning Outcomes. Development Process

Slide 1 CS 170 Java Programming 1 Expressions Duration: 00:00:41 Advance mode: Auto

Grade Point Scales Standard Honors AP/College A B C D F Sample file

AP Computer Science Unit 1. Programs

CS111: PROGRAMMING LANGUAGE II

PRIMITIVE VARIABLES. CS302 Introduction to Programming University of Wisconsin Madison Lecture 3. By Matthew Bernstein

Question: Total Points: Score:

CEN 414 Java Programming

Data Types and the main Function

Express Yourself. What is Eclipse?

Building Java Programs. Chapter 2: Primitive Data and Definite Loops

Claremont McKenna College Computer Science

CS125 : Introduction to Computer Science. Lecture Notes #4 Type Checking, Input/Output, and Programming Style

CS 101 Fall 2006 Midterm 1 Name: ID:

Lecture- 5. Introduction to Microsoft Excel

Building Java Programs

BlueJ Demo. Topic 1: Basic Java. 1. Sequencing. Features of Structured Programming Languages

Programming with Java

Python Programming Exercises 1

This is a combination of a programming assignment and ungraded exercises

CS110: PROGRAMMING LANGUAGE I

Getting started with Java

1) Log on to the computer using your PU net ID and password.

COMP 250 Winter 2011 Reading: Java background January 5, 2011

Fundamentals of Programming. Lecture 3: Introduction to C Programming

Darrell Bethea May 10, MTWRF 9:45-11:15 AM Sitterson 011

Peer Instruction 1. Elementary Programming

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #06 Loops: Operators

CSCD 255 HW 2. No string (char arrays) or any other kinds of array variables are allowed

Lecture 1. Types, Expressions, & Variables

Lecture 8 " INPUT " Instructor: Craig Duckett

Welcome to the Primitives and Expressions Lab!

Tester vs. Controller. Elementary Programming. Learning Outcomes. Compile Time vs. Run Time

Assignment #2: Intro to Java Due: 11AM PST on Wednesday, July 12

Overview. Lab 5 Methods and Parameters

Elementary Programming

Activity 1: Introduction

Anatomy of a Java Program: Comments

printf( Please enter another number: ); scanf( %d, &num2);

Lecture 6. Assignments. Java Scanner. User Input 1/29/18. Reading: 2.12, 2.13, 3.1, 3.2, 3.3, 3.4

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements

St. Edmund Preparatory High School Brooklyn, NY

LabVIEW. Table of Contents. Lesson 1. Pre-reqs/Technical Skills Basic computer use

Building Java Programs

Expressions and Casting. Data Manipulation. Simple Program 11/5/2013

Outlook Web Access. In the next step, enter your address and password to gain access to your Outlook Web Access account.

CS 1110 SPRING 2016: GETTING STARTED (Jan 27-28) First Name: Last Name: NetID:

CPSC 150 Laboratory Manual. Lab 1 Introduction to Program Creation

Java Foundations: Introduction to Program Design & Data Structures, 4e John Lewis, Peter DePasquale, Joseph Chase Test Bank: Chapter 2

EXCEL BASICS: MICROSOFT OFFICE 2010

ASSIGNMENT 1 First Java Assignment

SharePoint 2010 Tutorial

Entry Point of Execution: the main Method. Elementary Programming. Compile Time vs. Run Time. Learning Outcomes

Basics of Java Programming

Question: Total Points: Score:

Primitive data, expressions, and variables

EXCEL BASICS: MICROSOFT OFFICE 2007

Add Subtract Multiply Divide

Tutorials. Tutorial every Friday at 11:30 AM in Toldo 204 * discuss the next lab assignment

Expressions and Casting

CS2900 Introductory Programming with Python and C++ Kevin Squire LtCol Joel Young Fall 2007

Monroe Township High School AP Computer Science A Summer Packet

Excel Basics Fall 2016

Transcription:

Solo Complete all four programs by yourself Print programs 1, 2, 3, and 4, staple them together (or lose points) and turn in to your section leader or Rick if Cody is your SL from 9:55-10:01 am Wednesday, 31-August (at the beginning of lecture). See the end of this document. Read it before printing any solution! Use Eclipse to write Java code and run programs. Fix compile time errors as you type. Become familiar with running programs with standard input and output. Solve three problems that follow the algorithmic pattern of Input, Process, Output. In this project you are asked to implement four programs where each program is one Java class with one main method (one example is given below). The first program is in the context of a tutorial describing the steps required to create a new project, a new class, and how to run the class as a Java program. It is assumed you are using a CS Lab (either 228 GS or 930 GS) or you have installed Eclipse on your own computer and created a shortcut / alias / launcher that looks like this: 1) Welcome Click the Eclipse Icon Eclipse will start and may offer a Welcome page, which you should close (if it is visible) Create a new project by clicking on File > New > Java Project

Enter a name for your project after Project name: (First is used here) Press the Finish button in the lower right corner Create a class with File > New > Class After Name: type the name of the class you want to create. For this project, the first class you create will be called Welcome. After you type in Welcome, click the Finish button at bottom. Type in the following code as it is shown below. As you type, you may encounter squiggly red lines under portions of your code. This is the compiler telling you that you may have an error. For help about the compile time errors, hover the mouse over the red error mark. Once everything is typed in, save the file by going to File > Save. Saving the file compiles the code into a class file and updates error messages. Fix any errors before you go on. Save the file again. Select Run > Run As > Java Application At the bottom of the screen in the Console box, you should see output that says Welcome. What is your name?

Click on the console window to the right of this prompt Type in your name (input is green like Chris) and press the enter key The dialog should look like this (with a different name unless your name is Chris): Welcome, what is your name? Chris Hello Chris. I hope you are well :-) After running your program, print it with the Eclipse command File > Print Write a Java program that compute a student s cumulative grade point average (GPA) for three courses. Credits range from 0.5 to 15.0. Grades can be 0.0, 1.0, 2.0, 3.0, or 4.0. Test your program by running it with several different inputs where you know the expected results. dialog must look like this: Credits for course 1: 2.0 Grade for course 1: 2.0 Credits for course 2: 3.0 Grade for course 2: 4.0 Credits for course 3: 3.0 Grade for course 3: 4.0 GPA: 3.5 Grades range from 0.0 (an E) to 4.0 (an A) GPA is a weighted not simple average. To determine GPA, determine quality points, which is the product of a course grade times its credits. Sum all quality points and divide that sum by the total number of credits. For example, a 3.0 unit A (4.0) has 12.0 quality points and (3.0*4.0) and a 4.0 unit C (2.0) would have 8.0 quality points (4.0*2.0). The GPA for these two courses is (12.0 + 8.0) / (3.0 + 4.0) = 2.8571428571 (not the simple average of (4.0 + 2.0) / 2.0 = 3.0. Do not round the answer. You may see 1 to 14 digits to the right of the decimal point after GPA: After testing your program with several test cases, print it with the Eclipse command File > Print It is said that Albert Einstein used to take great delight in baffling friends with the puzzle below. First, write the number 1089 on a piece of paper, fold it, and hand it to a friend for safekeeping. What you wrote down is not to be read until you have completed your amazing mental feat. Next, ask your friend to write down any three-digit number, emphasizing that the first and last digits must differ by at least two. Close your eyes or turn your back while this is being done. Better still, have someone blindfold you.

After your friend has written down the three-digit number, ask him to reverse it, then subtract the smaller from the larger. Example: 654-456 = 198. Once this is done, tell your friend to reverse the new number. Example: 198 becomes 891. Next ask your friend to add the new number and its reverse together. Example: 198 + 891 = 1089. If all goes as planned, your friend will be amazed. The number you wrote down at the start, 1089, will always be the same as the end result of this mathematical trick. Your program dialog should look like this when the user enter 541 Enter a 3 digit number where the first and last digits differ by at least two: 541 541 -- original 145 -- reversed 396 -- difference 693 -- reverse of the difference 1089 -- sum of 'difference' and 'reverse of the difference' Notes You don t need to error check the 3 digit number. Assume it is 3 non-zero digits and the first and last digits differ by at least 2. Whereas 046 and 485 are invalid, 486 or 385 are valid inputs. Remember that 541 % 10 is 1 Remember that 541 / 100 is 5 Math.max(a, b) returns the larger of a and b (not in the book, but needed) Math.min(a, b) returns the smaller of a and b (not in the book, but needed) After testing your program with several test cases, print it with the Eclipse command File > Print Write a Java program that hides a message in five words. Use one of the characters in the five input strings to spell out one new word. Run your program with the following input and make up at least one other message: Enter five words: cheap energy can cause problems Enter five integers: 4 2 1 0 5 Secret message: peace Notes The String charat(int) method returns a character, but with + it is treated as if it were an int. So instead of concatenating five characters, it could add up to the numeric equivalents used to store the characters. Consider the following code that outputs 195 (97 for 'a' plus 98 for 'b'): String astring = "ab"; System.out.println(aString.charAt(1) + astring.charat(0)); Output: 195 Placing a string literal up front fixes the problem. This code prints the string Secret message: ad String astring = "abcde"; System.out.println("Secret message: " + astring.charat(0) + astring.charat(3));

So make sure you start your output with the label "Secret message: ". This forces charat to return value to become the character you seek. After testing your program with at least two test cases, print it with the Eclipse command File > Print 100 pts / 4 You the three printed programs together for turnin / 4 Code in would compile and attempts to solve Program 1 / 4 Code in would compile and attempts to solve Program 2 / 4 Code in would compile and attempts to solve Program 3 / 36 Style and Design / 6 Each program has your name as a comment / 6 Each program has a one or two description of what the program does / 6 The output is exactly as requested (or very very close) / 6 You used meaningful identifiers for program names (same as file names) and variables / 6 You used meaningful names for all identifiers / 6 Your code is consistently formatted with the Eclipse command: File > Source > Format Sample Documentation for Program 3) Einstein Number with the required comments: Programmer: YOUR NAME It is said that Albert Einstein used to take great delight in baffling friends with a puzzle represented by this program. This program reads a 3 digit number, does some manipulations to that integer, and always arrives at 1089. java.util.scanner; EinsteinNumber { main(string[] args) { Scanner keyboard = Scanner(System. );