Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 2 CISC 1115 Start a new Java program. It should begin by printing, as part of the output (in addition to the comment at

Lab 2 CISC 1115

Start a new Java program. It should begin by printing, as part of the output (in addition to the comment at the beginning of your code, a header for the lab (or homework) that looks like the following:

--------------------------------------------------------------------------

Your name Due Date

CISC 1115 MY11 Lab2

--------------------------------------------------------------------------

Write a program that will read a double from the keyboard, which represents a dollar and cents amount, such as 7325.67, and prints out:

7325.67 is 7 thousand 3 hundred 2 tens 5 dollars and 67 cents

Input of 123 54 would print

123.54 is 0 thousand 1 hundred 2 tens 3 dollars and 54 cents

Or, for input of 100.00 the program will print

100.0 is 0 thousand 1 hundred 0 tens 0 dollars and 0 cents

Input of 12.54 would print

12.54 is 0 thousand 0 hundred 1 tens 2 dollars and 54 cents

Another example,

0.54 is 0 thousand 0 hundred 0 tens 0 dollars and 54 cents

One way to do this is to use casting, integer division and the mod operator (%) as we will discuss in the lecture but feel free to go your own way.

One set of code should work for any amount read in as a double. Assume the input amount is never greater than 99999.99

Print the code and run a number of examples like those above.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Murach's SQL Server 2012 For Developers

Authors: Bryan Syverson, Joel Murach, Mike Murach

1st Edition

1890774693, 9781890774691

More Books

Students also viewed these Databases questions