Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*Heres Lab 3 code public class Lab3 { public static void main(String args[]) { //Invoke methods sum(); payroll(); } //Sum method definition public static void

image text in transcribed

*Heres Lab 3 code

public class Lab3 { public static void main(String args[]) { //Invoke methods sum(); payroll(); } //Sum method definition public static void sum(){ //Variable declaration int num1; int num2; //Variable initialization num1 = 5; num2 = 6; //Compute sum int sum = num1 + num2; System.out.println("The sum of " + num1 + " plus " + num2 + " is " + sum+"."); } //Payroll method public static void payroll(){ //Variable declaration float pay; float payRate; int hoursWorked; //Initialization hoursWorked = 35; payRate = 12.5f; //Compute Pay pay = hoursWorked * payRate; //Display values System.out.println("Hours worked: " + hoursWorked); System.out.println("Pay rate: " + String.format("%.2f",payRate)); System.out.println("Pay: " + String.format("%.2f",pay)); } }

Purpose The purpose of the lab is to learn how to perform simple console IO in Java. Process Create a new project named Lab 4 that reuses the code from Lab 3. In Lab 4: Remove the code that computes the sum Prompt the user for the number of hours worked and the pay rate Modify the payroll method to accept the hours worked and pay rate Call the payroll method with these inputs . . .Rename the payroll method to use a better name Your output should appear similar to the following where the text in red is the user's input: Enter hours: 35 Enter pay rate: 12.50 You worked 35 hours at 12.50 per hour. Your pay is 437.50 Turn in your lab the same way as before

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_2

Step: 3

blur-text-image_3

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

Creating A Database In Filemaker Pro Visual QuickProject Guide

Authors: Steven A. Schwartz

1st Edition

0321321219, 978-0321321213

More Books

Students also viewed these Databases questions