Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need 2 java programs with comments to show what each does This program will figure out the change required for a purchase. Start by

I need 2 java programs with comments to show what each does

This program will figure out the change required for a purchase. Start by asking the user for price of product and amount tendered. Assume user will give a larger value for amount tendered. Read in each as a double. Report back to user the number of each denomination of change is required to complete transaction. Working with integers only is much easier. (Hint- multiply inputs by 100 and cast to be an integer in order to work with pennies) Use a step by step approach to calculate the number of dollars first, then move to quarters with what is left. Have output look as shown on back.

Program 2: StringStuff.java

Ask the user to input a multiple word phrase and store in a String. Using the methods from the String class, report back to the user the following:

length of string(number of characters) substring of original with first and last letter missing a random letter of string( use the random class to help pick an index and report this index with the solution) the index location for the first space within the string

Note: Spaces are considered letters and count in number of characters.

Tips for good grades: -Use of your programs should be user friendly- I should not have to wonder if the computer is waiting for me to input a value without having been given direction to. -The program should repeat my input back to me in some way, verifying that it was typed in correctly. -Programs should begin and end with friendly messages. -Make sure you use comments where needed and use variable names that make sense, some of your grade will depend on program style as well as the use of your program. -I will use the project grading sheet, so look over each area so you do not lose credit. -Test your own projects thoroughly before you hand them in.

Each of these programs must be done in a separate file. Name them Change.java and StringStuff.java. (The .java is added automatically when you save a java file) This means you should be naming the main class in each file these names as well. If you do not name these files correctly you will lose points.

Hand in electronically (NOT E-mail!!!) In Blackboard: Place all two files into a zip folder called projectone_lastname.zip Open blackboard for this course Click on Programming Projects (left side of screen) Click on correct Project to submit Click in Attach files box Browse my computer (Click Start New first if this is not your first submission) Attach the zipped folder from step one Click Submit on bottom right You will get a confirmation e-mail

SAMPLE OUTPUT: Program 1 sample output of solution:

Welcome to my Change maker. Please enter cost of product: $ 34.82 Please enter amount tendered: $ 40.00

Your change is: $ 5.18 5 one-dollar bills 0 quarters 1 dimes 1 nickels 3 pennies

Thank you for your business!

Program 2 sample output of solution:

Welcome to my string manipulator program Please enter a string that may have multiple words: Hello classmates

Results: length of string = 16 substring = ello classmate random letter (picked index 4) = o (Note this is different each run) index of first space = 5

Thanks for using my program!

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

More Books

Students also viewed these Databases questions

Question

to encourage a drive for change by developing new ideas;

Answered: 1 week ago

Question

4 What are the alternatives to the competences approach?

Answered: 1 week ago