Question

In: Computer Science

Fundamentals of Programming USING JAVA Please copy here your source codes, including your input and output...

Fundamentals of Programming

USING JAVA

Please copy here your source codes, including your input and output screenshots. Please upload this document along with your source files (i.e., the .java files) on Blackboard by the due date.

1.

(Display three messages) Write a program that displays Welcome to Java, Welcome to Computer Science, and Programming is fun.

2.

(Convert feet into meters) Write a program that reads a number in feet, converts it to meters, and displays the result. One foot is 0.305 meter. Here is a sample run:

Enter a value for feet: 16.5

16.5 feet is 5.0325 meters

3.

(Financial application: compute taxes) Listing 3.5, ComputeTax.java, gives the source code to compute taxes for single filers. Complete this program to compute taxes for all filing statuses.

4.

(Financial application: payroll) Write a program that reads the following information and prints a payroll statement:

Employee’s name (e.g., Smith)

Number of hours worked in a week (e.g., 10)

Hourly pay rate (e.g., 9.75)

Federal tax withholding rate (e.g., 20%)

State tax withholding rate (e.g., 9%)

A sample run is as follows:

Enter employee’s name: Smith

Enter number of hours worked in a week: 10

Enter hourly pay rate: 9.75

Enter federal tax withholding rate: 0.20

Enter state tax withholding rate: 0.09

Employee Name: Smith

Hours worked: 10.0

Pay Rate: $9.75

Gross Pay: $97.5

Deductions:

   Federal Withholding (20.0%): $19.5

   State Withholding (9.0%): $8.77

   Total Deduction: $28.27

Net Pay: $69.22

5.

(Find the largest n such that n3<12,000) Use a while loop to find the largest integer n such that n3 is less than 12,000.

Solutions

Expert Solution

Answer 1.

Here I displayed all three message in three lines.

import java.util.*;
public class Main
{
   public static void main(String[] args) {
       System.out.println("Welcome to Java");
       System.out.println("Welcome to Computer Science");
       System.out.println("Programming is fun");
      
   }
}

Output:
Welcome to Java

Welcome to Computer Science

Programming is fun

Answer 2.

Here I convert foot into meters according to questions One foot is equals to 0.305 meters(please check real value of one foot from your side).

import java.util.*;
public class Main
{
   public static void main(String[] args) {
   Scanner sc=new Scanner(System.in);
   double mtr=0.305, result;
       System.out.print("Enter a value for feet:");
       double ft=sc.nextDouble();
      
       result= ft*mtr;
       System.out.println(ft+" feet is "+result+" meters ");
      
      
      
   }
}

Output:

Enter a value for feet: 16.5

16.5 feet is 5.0325 meters

Answer 4:

Here I used varibales name such as

noh : number of hours worked
hpr : hourly pay rate
ftw : federal tax withholding rate
stw : state tax withholding rate
gp : Gross pay
fw : Federal Withholding
sw : State Withholding
td : Total Deduction


import java.util.*;
public class Main
{
   public static void main(String[] args) {
   Scanner sc=new Scanner(System.in);
  
       System.out.println("Enter employee’s name :");
       String name=sc.next();
       System.out.println("Enter number of hours worked in a week :");
       int noh=sc.nextInt();
       System.out.println("Enter hourly pay rate :");
       double hpr=sc.nextDouble();
       System.out.println("Enter federal tax withholding rate :");
       double ftw=sc.nextDouble();
       System.out.println("Enter state tax withholding rate :");
       double stw=sc.nextDouble();
      
      
       System.out.println("Employee Name :"+name);
       System.out.println("Hours worked :"+noh);
       System.out.println("Pay Rate : $"+hpr);
   double    gp= noh*hpr;
       System.out.println("Gross Pay : $"+gp);
       System.out.println("Deduction :");
       double fw,sw,td;
       fw= ((ftw/1)*gp);
       sw=((stw/1)*gp);
       td= fw+sw;
      
       System.out.println("Federal Withholding : $"+fw);
       System.out.println("State Withholding : $"+sw);
       System.out.println("Total Deduction : $"+td);
       System.out.println("Net Pays: $"+(gp-td));
      

}
}

Answer 5 :

import java.util.*;
public class Main
{
   public static void main(String[] args) {
     

  
int n=0;
while(true) {
if(n*n*n<12000) {
n++;
}
else
break;
}
System.out.println("The largest integer of n less than 12000 is: "+(n-1));
    }
}

Output:

The largest integer of n less than 12000 is: 22


Related Solutions

[JAVA] Please make sure there are FIVE (5) different source codes. Do not copy your answers...
[JAVA] Please make sure there are FIVE (5) different source codes. Do not copy your answers or someone’s else answers from different Cheggs. I did not post this question to see the same answers. All information that was given is included. Thank you. I will upvote if you do it properly. Task 1: Add three methods: union, intersection, and difference to the interface BagInterface for the ADT bag. Task 2: Implement the three methods, union, intersection, and difference, for the...
Programming Steps: (In Java) (Please screenshot your output) A. Files required or needed to be created:...
Programming Steps: (In Java) (Please screenshot your output) A. Files required or needed to be created:    1. Artist.java (Given Below)    2. p7artists.java (Input file to read from)    3. out1.txt (Output file to write to) B. Java programs needed to writeand create:    1. MyArtistList.java:    - Contains the following:        1. list - public, Arraylist of Artist.        This list will contain all entries from "p7artists.txt"        2. Constructor:        A constructor that accepts one...
JAVA PROGRAMMING Objectives JAVA Practice incremental development. Practice getting input from and printing output for the...
JAVA PROGRAMMING Objectives JAVA Practice incremental development. Practice getting input from and printing output for the user. Write a program with conditional statements. Write a program with loops. Specifications Think of three countries you’d like to travel to and look up the conversion rate between dollars and the money used in those countries. (See http://www.ratesfx.com/ rates/rate-converter.html for conversion rates.) Write a program that will convert money from dollars into each of those three types of currency, or from one of...
java program: Input and output the following details. Your program can only receive the correct input....
java program: Input and output the following details. Your program can only receive the correct input. (For example: a notification will be given if you not enter Char data type for Name) Name: Ali bin Ahmad Occupation: Technician Age: 30 Hometown: Negeri Sembilan Years of Service: 12 Gender: Male
Java and please have screenshots with source code and output \item[(1)] A palindrome is a string...
Java and please have screenshots with source code and output \item[(1)] A palindrome is a string that reads the same forwards as backwards. Using only a fixed number of stacks and queues, the stack and queue ADT functions, and a fixed number of int and char variables, write an algorithm to determine if a string is a palindrome. Assume that the string is read from standard input one character at a time. The algorithm should output true or false as...
Using SAS programming Please include the syntax and output of the information: In a study of...
Using SAS programming Please include the syntax and output of the information: In a study of factors thought to be responsible for the adverse effects of smoking on human reproduction, cadmium level determinations (nanograms per gram) were made on placenta tissue of a sample of 14 mothers who were smokers and an independent random sample of 18 nonsmoking mothers. The results were as follows- Nonsmokers: 10.0, 8.4, 12.8, 25.0, 11.8, 9.8, 12.5, 15.4, 23.5, 9.4, 25.1, 19.5, 25.5, 9.8, 7.5,...
Using SAS programming Please include the syntax and output of the information: In a study of...
Using SAS programming Please include the syntax and output of the information: In a study of factors thought to be responsible for the adverse effects of smoking on human reproduction, cadmium level determinations (nanograms per gram) were made on placenta tissue of a sample of 14 mothers who were smokers and an independent random sample of 18 nonsmoking mothers. The results were as follows- Nonsmokers: 10.0, 8.4, 12.8, 25.0, 11.8, 9.8, 12.5, 15.4, 23.5, 9.4, 25.1, 19.5, 25.5, 9.8, 7.5,...
IT344- Database Management Systems book Fundamentals Of Database Systems please no copy and paste Use your...
IT344- Database Management Systems book Fundamentals Of Database Systems please no copy and paste Use your own words , No handwriting. Users prefer to stream high quality videos (e.g., watch YouTube) without lagging (i.e., slow loading). In this context, explain how UDP is better than TCP when streaming videos?
java.. please dont change the format and give me an output sample! user need to input...
java.. please dont change the format and give me an output sample! user need to input k. public class Josephus {    /**    * All persons sit in a circle. When we go around the circle, initially starting    * from the first person, then the second person, then the third...    * we count 1,2,3,.., k-1. The next person, that is the k-th person is out.    * Then we restart the counting from the next person, go...
SOLVE USING R. COPY AND PASTE R INPUT AND OUTPUT. Fifteen turkey hens were randomly assigned...
SOLVE USING R. COPY AND PASTE R INPUT AND OUTPUT. Fifteen turkey hens were randomly assigned to three groups of five. One group was given diet A, the second group diet B, and the third group diet C. We wish to know if there is a difference in the weight of eggs produced by the birds on these diets, and if so, which diet results in the largest eggs. The data are the mean weights of ten eggs from each...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT