Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CIS 162 Lab 2 Conversions Objectives After completing this lab, you should be able to: create a project and class read data from the keyboard

image text in transcribedimage text in transcribed

CIS 162 Lab 2 Conversions Objectives After completing this lab, you should be able to: create a project and class read data from the keyboard using the Scanner class make calculations using assignment statements and variables display results using the print () and println() methods . a Lab Activity #1 - Convert to seconds 1. Start BlueJ 2. In your CIS 162 Labs folder, create a new project called Lab2. 3. Create a new Class called ConvertToSeconds" 4. Edit the top comment section to describe the class and write your name as the author. 5. Remove the two automatically generated methods. 6. Create a main method (see Activity 1.2.3 in book) 7. Prompt the user to enter three integers for hours, minutes and seconds. 8. Use variables with meaningful names 9. Calculate and display the number of equivalent seconds 10. Run your program with 4 hours, 1 minute, 0 seconds. 11. When working correctly, copy the instructions inside of the main method to the corresponding zyLab in Chapter 3 for grading. Make sure to click the link found on Weekly Assignments / Week 2 / Lab 2 on Blackboard to get to zybooks. Sample Input/Output Run your program with 4 hours, 1 minute, 0 seconds. The output should be: 14460 seconds Lab Activity #2 - Convert from seconds NOTE: See example code (Integer Division AndModExample) posted on Blackboard. 1. Create a new Class called "ConvertFromSeconds 2. Prompt the user to enter one integer for the number of seconds. 3. Calculate and display the number of equivalent hours, minutes and seconds (refer to section 3.6 about integer division and the remainder operator) hours = numSeconds / 3600; numSeconds = numSeconds $ 3600; // remainder seconds 4. When working correctly, copy the instructions inside of the main method to the corresponding zyLab in Chapter 3 for grading. Make sure to click the link found on Weekly Assignments / Week 2/ Lab 2 on Blackboard to get to zybooks. Sample Input/Output: Run your program entering 3661 as the number of seconds The output should be: Hours: 1 Minutes: 1 Results printed in 3 lines Seconds: 1 Lab Activity #3 - Convert to dollars 1. Create a new Class called ConvertToDollars" 2. Prompt the user to enter four integers for quarters, dimes, nickels and pennies. 3. Calculate the total number of cents by combining quarters, dimes, nickels and pennies. 4. Divide by 100.0 and place in a double 5. Display the equivalent in dollars and cents. 6. When working correctly, copy the instructions inside of the main method to the corresponding zyLab in Chapter 3 for grading. Make sure to click the link found on Weekly Assignments / Week 2 / Lab 2 on Blackboard to get to zybooks. NOTES: Work your solution taking into consideration that 1 dollar contains 100 pennies; 1 quarter contains 25 pennies, etc. We will learn how to format numbers and currencies later, for now use the following instruction to form at the result. System.out.println("Dollars: $" + ); Variable name used to do the calculation / 100.0 Sample Output: When running your program enter 4 for Quarters and 1 for all the other coins The output should be: Dollars: $1. 16

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

JDBC Database Programming With J2ee

Authors: Art Taylor

1st Edition

0130453234, 978-0130453235

More Books

Students also viewed these Databases questions

Question

=+4 Develop and deliver the CCT program.

Answered: 1 week ago