1 Project 5: Leap Years. 222 Leap Years Write a program that reads an integer value from the user representing a year and determines if the year is a.

Slides:



Advertisements
Similar presentations
Making Choices in C if/else statement logical operators break and continue statements switch statement the conditional operator.
Advertisements

1 Project 6: Tic Tac Toe. 2 Tic Tac Toe A Challange Project 10 Points extra credit on final grade OK to work in groups of 2 or 3.
Introduction to C Programming
1 Generics and Using a Collection Generics / Parameterized Classes Using a Collection Customizing a Collection using Inheritance Inner Classes Use of Exceptions.
1 Lab Session-3 CSIT 121 Spring’05 Division rules Operator precedence rules Lab Exercise.
1 Project 6: Cats in Tree. 2 Project 3: Cats in Tree In this project you will Create a class definition for a Cat class. Populate a BST with Cat information.
1 Project 7: Huffman Code. 2 Extend the most recent version of the Huffman Code program to include decode information in the binary output file and use.
1 Project 5: Median. 2 The median of a collection of numbers is the member for which there are an equal number less than or equal and greater than or.
1 Project 7: My Photo Album Graded Project. 2 Assignment Write a web app to permit users to upload and view photos. User can keep up to five photos on.
CONTROL STATEMENTS IF-ELSE, SWITCH- CASE Introduction to Computer Science I - COMP 1005, 1405 Instructor : Behnam Hajian
1 Project 4: XML Product Browser (Not Graded). Objectives This project is an exercise of the following knowledge and skills: Accessing and displaying.
1 Project 4: Vehicle Inventory. 2 Write a program to read a text file containing information about vehicles and output the information First in the order.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
1 Project 5: New Venue. 2 New Venue Based on the posted New Venue scenario 077_Ticket_Booth_Scenarios.pdf.
1 Project 7: Northwind Traders Order Entry. 2 Northwind Order Entry Extend the Select Customer program from Project 6 to permit the user to enter orders.
Discussion 4. Labs public MyPoint(double xInit, double yInit ) { MyPoint p = new MyPoint(0, 0); } ClassProblem.java recursive java.lang.StackOverflowError.
Liang, Introduction to C++ Programming, (c) 2007 Pearson Education, Inc. All rights reserved X1 Chapter 3 Control Statements.
11 Project 2 Temperature Conversion (Not graded).
11 Project 2 Towers of Hanoi. 22 Towers of Hanoi is a well known puzzle that can be very difficult to solve manually but can be programmed very easily.
1 Flight Times. 2 Problem Specification 3 Additional Specifications You may assume that the input is a valid 24 hour time. Output the time entered by.
Week81 APCS-AB: Java Unit Testing Information today from “Unit Testing in BlueJ” October 28, 2005.
1 Project 5: Printing Address Labels. 2 Assignment Write a Windows forms program to display and print a set of address labels. Input from a csv file.
1 Project 3 The Kumquat Society Conference. 2 Conference Registration In this project you will write a program to handle a conference registration. The.
Project 3: Ticket Printer
Object Oriented Programming (OOP) LAB # 1 TA. Maram & TA. Mubaraka TA. Kholood & TA. Aamal.
Programming Fundamentals I Java Programming Spring 2009 Instructor: Xuan Tung Hoang TA: Tran Minh Trung Lab 03.
1 COP 2510 Programming Concepts Spring credit hours Instructor:Dr. Rollins Turner ENB 343F Office Hours: MW 11:00 AM – 12:00.
The Hashemite University Computer Engineering Department
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
1 Project 2: Using Variables and Expressions. 222 Project 2 Overview For this project you will work with three programs Circle Paint Ideal_Weight What.
1 Project 3 String Methods. Project 3: String Methods Write a program to do the following string manipulations: Prompt the user to enter a phrase and.
1 Project 1: Tickets. 2 Class Ticket Write a definition for class Ticket. A Ticket object corresponds to a physical ticket for a stage show. Attributes.
1 Project 2: Sorting Cats. Write a C++ console application to read a text file containing information about cats and output the information to the screen.
1 Project 4 Address Lookup. Project 4 Write an ASP.NET app that permits users to retrieve addresses from a potentially large list of addresses. There.
1 Project 3: Farey Sequences. 2 Farey Sequences Further details about Farey sequences, and more examples, can be found in the Wikipedia article:
1 Project 7: Looping. Project 7 For this project you will produce two Java programs. The requirements for each program will be described separately on.
11 Project 2 Temperature Conversion. 22 Project 2: Temperature Conversion Write an ASP.NET Web Forms app to convert temperatures from Fahrenheit to Celsius.
CS1010: Programming Methodology
1 Flow of Control Chapter 5. 2 Objectives You will be able to: Use the Java "if" statement to control flow of control within your program.  Use the Java.
1 Project 4: Computing Distance. 222 Computing Distance Write a program to compute the distance between two points. Recall that the distance between the.
Introduction to Programming Python Lab 7: if Statement 19 February PythonLab7 lecture slides.ppt Ping Brennan
1 Project 4: Palindrome Detector. 2 Assignment Write a C++ program that reads a line of text from the keyboard and reports to the user whether the text.
1 Project 4: Venue Sort. 2 This project is an exercise in Using C++ strings. Operator overloading. Text File Input.
General Condition Loop A general condition loop just loops while some condition remains true. Note that the body of the loop should (eventually) change.
1 Project 5 Eyeglass Rx User Control. Eyeglass Rx Earlier in the semester we looked at an eyeglass prescription as an example of an HTML table. 2.
1 Project 15: Animals Using Derived Classes and Inheritance.
1 Project 6: New Venue. 2 New Venue Based on the posted New Venue scenario
Variable scope. Variable Scope Variables do not live forever. Failing to take that into account leads to problems. Let's look at an example. Let's write.
1 Project 8: Tic Tac Toe. 2 Assignment Write an HTML and JavaScript page that pemits users to play Tic Tac Toe. Both players use a single browser. Alternating.
1 Project 7: Ticket_Booth_0 Using XML. 2 Ticket Booth 0 Base Level 0 of the real Ticket Booth program. Gets information for a single venue from an XML.
1 Project 12: Cars from File. This is an extension of Project 11, Car Class You may use the posted solution for Project 11 as a starting point for this.
1 Project 6: Northwind Orders. 2 The Northwind Traders Database The Northwind Traders database was created by Microsoft for training and demonstration.
User-Written Functions
2.5 Another Java Application: Adding Integers
Introduction to Programming
Chapter 3 Control Statements Lecturer: Mrs Rohani Hassan
INPUT STATEMENTS GC 201.
Control Statement Examples
Introduction to Programming
Use proper case (ie Caps for the beginnings of words)
MSIS 655 Advanced Business Applications Programming
Introduction to Programming
For Loops.
Programming Assignment #1 12-Month Calendar—
Programming in JavaScript
Programming in JavaScript
Introduction to Programming
Input, Variables, and Mathematical Expressions
CS105 Introduction to Computer Concepts JavaScript
CHAPTER 6 Testing and Debugging.
Presentation transcript:

1 Project 5: Leap Years

222 Leap Years Write a program that reads an integer value from the user representing a year and determines if the year is a leap year in the Gregorian calendar (the normal calendar that we use.) A year is a leap year if it is divisible by 4, unless it is also divisible by 100 but not by 400. Output an error message for any input value less than 1582 (the year the Gregorian calendar was adopted.) (This is Programming Project PP 5.1 in the textbook.)

333 Leap Years Test your program using the following data: 1400Error 1900Not leap year 2000Is a leap year 2003Not a leap year 2004A leap year 2100Not a leap year

444 General outline of your main function Declare your variables The only variable you will need is an int to hold the year. Get the input from the user. Check for the year being valid Greater than or equal to Determine if the year is a leap year, and output the result.

555 Sample Run Your output should be similar in format to that shown in the sample run shown on the next slide.

666 Error case

777 Writing the Program Start with a stub Just output the prompt: Enter a year greater than 1581 Compile and test after each step. Always have a working program! Add code to get the input. Instantiate a Scanner. Remember to import java.util.Scanner Declare an int variable for the input, year. Read the input, year. Output the year, so that you can verify that you read it correctly.

888 Writing the Program Check for the year being less than If it is, output an error message and terminate. If the year is greater than or equal to 1582, check if it is divisible by 4. If it is not, the year is not a leap year. Output the result and terminate. At this point you know that the year is valid and is divisible by 4. So it could be a leap year. Check if it is divisibe by 100. If not, it is a leap year. Output the result and terminate.

999 Writing the Program If you reach this step, the year is divisible by 100. Check if it is also divisible by 400. If it is, it is a leap year. Output the result and terminate. If you reach this point, the year is divisible by 100 but not by 400. That means that it is not a leap year. Output the result and terminate.

10 Implementation Hint You will need multiple levels of if... else At each step, add another "else" if (xxx) { } else { if (yyy) {... } else {... }

11 Submission Put your Java source file into a folder and zip it. Submit your zipped Java source file via Canvas Assignments. Project is due by 11:59 PM Sunday, February 14 Sections 001 and 002 Monday, February 15 Sections 003 and 004

12 Ground Rules It is OK to discuss the project with other students BUT Do not share your code with other students. Before or after submitting the project. Do not copy any other student’s code. Or even look at it. Do not let anyone copy or examine your code.

Ground Rules Except for code posted on the class web site Do not copy code from the Internet or any other source (other than the textbook.) Do not ask for help on an Internet forum. If you need help, ask your instructor or a TA. Come to lab and help sessions. Write your own code.