InterestRate Create an InterestRate class and InterestRateViewer client class to do the following: A person is purchasing an item with their credit card.

Slides:



Advertisements
Similar presentations
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Advertisements

Computer Programming Lab(7).
CSCI 6962: Server-side Design and Programming Input Validation and Error Handling.
Computer Programming Lab 8.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 2 1 Chapter 2 Primitive.
Primitive Data Types and Operations. Introducing Programming with an Example public class ComputeArea { /** Main method */ public static void main(String[]
1 LECTURE#7: Console Input Overview l Introduction to Wrapper classes. l Introduction to Exceptions (Java run-time errors). l Console input using the BufferedReader.
Mathematical Operators  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course. Introduction to Computers and Programming in.
Introduction to Computers and Programming Lecture 3: Variables and Input Professor: Evan Korth New York University.
School of Computing Science CMT1000 Ed Currie © Middlesex University Lecture 4: 1 CMT1000: Introduction to Programming Ed Currie Lecture 5a: Input and.
Chapter 2 - Introduction to Java Applications
1 Introduction to Console Input  Primitive Type Wrapper Classes  Converting Strings to Numbers  System.in Stream  Wrapping System.in in a Buffered.
Chapter 3b Standard Input and Output Sample Development.
COMPSCI 125 Spring 2005 ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 3: IO *Standard Output *Formatting Decimal.
JOptionPane class. Dialog Boxes A dialog box is a small graphical window that displays a message to the user or requests input. A variety of dialog boxes.
Warm-Up: Monday, March 3 List all devices you can think of that can be used to input information into the computer.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 62 – Manipulating Data Using Methods – Day 1.
Data Types Integer 15 StringHelloThere! Float/Real BooleanYes / No CharP.
Console Input. So far… All the inputs for our programs have been hard-coded in the main method or inputted using the dialog boxes of BlueJ It’s time to.
Basic Java Programming CSCI 392 Week Two. Stuff that is the same as C++ for loops and while loops for (int i=0; i
Java Programming: From Problem Analysis to Program Design, 3e Chapter 3 Introduction to Objects and Input/Output.
习 题 4.23 编写一个 applet ,读取一个矩形的边长,然后 用在 paint 方法中使用 drawString 方法画出用星组成 的空心矩形。程序应能画出边长从 1 到 20 的任何矩 形。
Chapter 2 – Continued Basic Elements of Java. Chapter Objectives Type Conversion String Class Commonly Used String Methods Parsing Numeric Strings Commonly.
Chapter 2: Java Fundamentals Type conversion,String.
 2000 Prentice Hall, Inc. All rights reserved. 1 Chapter 2 - Introduction to Java Applications Outline 2.1Introduction 2.2A Simple Program: Printing a.
Java Fundamentals 5. Java Programming: From Problem Analysis to Program Design, Second Edition2 Parsing Numeric Strings  Integer, Float, and Double are.
Variables When programming it is often necessary to store a value for use later on in the program. A variable is a label given to a location in memory.
Chapter 3 Java Input/Output.
1/28: Inputs, Variable Types, etc. Addition.java in depth Variable types & data types Input from user: how to get it Arithmetic operators.
Lecture 2 Objectives Learn about objects and reference variables.
Dialog Boxes.
FUNDAMENTALS 2 CHAPTER 2. OPERATORS  Operators are special symbols used for:  mathematical functions  assignment statements  logical comparisons 
Data Types – Reference Types Objective To understand what reference types are The need to study reference types To understand Java standard packages To.
GUI Graphical User Interface Each onscreen component and window is an object Object interaction makes communication and scoping challenging Event-driven.
Strings Mr. Smith AP Computer Science A. What are Strings? Name some of the characteristics of strings: A string is a sequence of characters, such as.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 3 Introduction to Objects and Input/Output.
Chapter 2 Input, Variables and Data Types. JAVA Input JAVA input is not straightforward and is different depending on the JAVA environment that you are.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 24.1 Test-Driving the Enhanced Car Payment.
Road map char data type Reading –Liang 5: Chapter 2: 2.7.4; 2.9; –Liang 6: Chapter 2: 2.7.4; 2.9 –Liang 7: Chapter 2: 2.7.4; 2.9.
REVIEW No curveballs this time …. PROBLEM TYPE #1: EVALUATIONS.
Wrapper Classes  Java offers a convenient way to incorporate, or wrap, a primitive data type into an object, for example, wrapping int into the class.
COP2800 – Computer Programming Using JAVA University of Florida Department of CISE Spring 2013 Lecture 39 – Command Line Args & Recursion Webpage:
Data Types – Reference Types Objective To understand what reference types are The need to study reference types To understand Java standard packages To.
Object Oriented Programming (OOP) LAB # 3 TA. Maram & TA. Mubaraka TA. Kholood & TA. Aamal.
AP Java 10/1/2015. public class Rolling { public static void main( String [] args) public static void main( String [] args) { int roll; int roll; for.
UFCFY5-30-1Multimedia Studio Coding for Interactive Media Fundamental Concepts.
Input, Output and Variables GCSE Computer Science – Python.
Java Programming Lecture 2
TemperatureConversion
Data Types – Reference Types
while Repetition Structure
Exceptions and User Input Validation
2.5 Another Java Application: Adding Integers
Dialogues and Wrapper Classes
Chapter 3 Java Input/Output.
Useful String Methods Cont…
Register Use Policy Conventions
Message, Input, Confirm, and Specialized Dialogs
AP Java 10/4/2016.
Chapter 3 Input/Output.
Message, Input, and Confirm Dialogs
We are starting JavaScript. Here are a set of examples
Java: Variables, Input and Arrays
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
Data Types and Maths Programming Guides.
JOptionPane class.
Chapter 2: Java Fundamentals cont’d
Exceptions Review Checked Vs. Unchecked Exceptions
Presentation transcript:

InterestRate Create an InterestRate class and InterestRateViewer client class to do the following: A person is purchasing an item with their credit card. Launch an input dialog window and have the user enter a short description of the item they are purchasing. Remember the JOptionPane.showInputDialog method that we used in an earlier class? Have the user input the amount of the purchase (in whole dollars – i.e. integer) into an input dialog window. Have the user input (into another input dialog window) the monthly interest rate they are paying on this purchase. Note that this may include decimal places (i.e. they would enter 5.75 to represent 5.75%). Your program should take these values and do the following:  Calculate the amount the user will be charged in interest if they don’t pay off this credit card purchase after the first month.  Print the following information to the console: You purchased for dollars. Your monthly interest rate is %. You will be charged in interest after the first month. Test with a few scenarios and print out your code and the results

Integer.parseInt int Integer.parseInt(String str) Use the static method parseInt of the Integer class to convert a string to an integer This is helpful when prompting a user in an input dialog window for an integer The string must be an integer or the program will throw a NumberFormatException error. Examples: String cash = “20"; int dollarAmt = Integer.parseInt(cash); Java Concepts 4.6 (Strings)

Double.parseDouble double Double.parseDouble(String str) Use the static method parseDouble of the Double class to convert a string to a floating point number This is helpful when prompting a user in an input dialog window for a floating point number The string must be an floating point number or an integer or the program will throw a NumberFormatException error. Examples: String cash = "19.75"; double cashAmt = Double.parseDouble(cash); double dollarAmt = Double.parseDouble("20"); Java Concepts 4.6 (Strings)