This code inputs 3 Numbers and Add them up
_____________________________________________________________
The user input his first middle, last name ,address , city and state and display it concatenated in a output message box.
_____________________________________________________________________
Changes in the economy have determined that for the EZ shipping company, a surcharge will be assessed on all packages that meet certain criteria. The surcharge is a function of the characteristics of the package and the zip code to which it is sent.
If the first digit of the zip code is a "4" then there is an additional surcharge of 5% on the shipping cost. If the first digit of the zip code is a "6" then there is an additional shipping cost surcharge of 9% based on the weight of the package. For all other zip codes there is an additional shipping cost surcharge of 14%. Additionally,t.
In addition to the surcharges, the regular charges for shipping are calculated as follows: For all weights under five pounds, the charge is $12.00.
For weights over five pounds, the charge is calculated as follows:
If length * width * height + weight is:
- Between 5.1 and 15, the charge is 14.00
- Between 15. 1 and 34, the charge is 17.00
- Between 34. 1 and 45, the charge is 21.00
- Between 45.1 and 60, the charge is 33.00
- Greater than 60, the charge is 105.00
- //Jazi Garciapackage shipping;import java.util.Scanner;public class Shipping {public static void main(String[] args) {{int zip;double weight;double length;double width;double height;double surcharge;double shippingCost;Scanner keyboard = new Scanner(System.in);System.out.println("(Hello) Welcome to EZ shipping company. \n We will determine how much youre shipping cost is as well as cover charge");System.out.println("How much does your package weight? ");weight = keyboard.nextDouble();System.out.println("What is the length of your package? ");length = keyboard.nextDouble();System.out.println("What is the width of your package? ");width = keyboard.nextDouble();System.out.println("What is the height of youre package? ");height = keyboard.nextDouble();double packages=length*width*height+weight;{shippingCost = 12;}if (weight >5){if (packages >=5.1 || packages <= 15){shippingCost= 14;}else if (packages >= 15.1 || packages <= 34 ){shippingCost= 17;}else if (packages >= 34.1 || packages <= 45){shippingCost= 21;}else if (packages >= 45.1|| packages <= 60){shippingCost= 33;}else if (packages > 60){shippingCost= 105;}}System.out.println("What is your zip code? ");zip = keyboard.nextInt();if(zip == 4){surcharge = shippingCost*0.05;}else if(zip == 6){surcharge = shippingCost*0.09;}else{surcharge = shippingCost*0.14;}double cost = shippingCost + surcharge;double total;total = shippingCost + surcharge+ packages;System.out.print("The Total Shipping Cost and Surcharge is $"+ cost);System.out.print(" Total is $"+ total);}}}
- The zip code and dimensions of the package
- The shipping cost
- The surcharge
- The total shipping cost (shipping cost plus surcharge)
Bar Chart:
Write a program that asks the user to enter today's sales for five stores. The program should display a bar chart comparing each store's sales. Create each bar in the bar chart by displaying a row of asterisks. Each asterisk should represnet $100 of sales. Do not accept any number less than $100.00. Here is an example of the program's output:
Enter today's sales for store 1: 1000[enter]
Enter today's sales for store 2: 1200[enter]
Enter today's sales for store 3: 1500[enter]
Enter today's sales for store 4: 0800[enter]
Enter today's sales for store 5: 1900[enter]
SALES BAR CHART
STORE 1: **********
STORE 2: ************
STORE 3: ***************
STORE 4: **********
STORE 5: *******************
package barchart;
import java.util.Scanner;
/**
*
* @author
*/
public class BarChart {
/**
*
*/
public static void main(String[] args)
{
int sales1, sales2, sales3, sales4,
sales5;
Scanner keyboard=new
Scanner(System.in);
System.out.print("Enter today's
sales for store 1: ");
sales1=keyboard.nextInt();
System.out.print("Enter today's
sales for store 2: ");
sales2=keyboard.nextInt();
System.out.print("Enter today's
sales for store 3: ");
sales3=keyboard.nextInt();
System.out.print("Enter today's
sales for store 4: ");
sales4=keyboard.nextInt();
System.out.print("Enter today's
sales for store 5: ");
sales5=keyboard.nextInt();
System.out.print("Store
1:");
for (int i=0; i<sales1; i+=100)
{
System.out.print("*");
}
System.out.println();
System.out.print("Store 2:");
for (int i=0; i<sales2; i+=100)
{
System.out.print("*");
}
System.out.println();
System.out.print("Store 3:");
for (int i=0; i<sales3; i+=100)
{
System.out.print("*");
}
System.out.println();
System.out.print("Store
4:");
for
(int i=0; i<sales4; i+=100)
{
System.out.print("*");
}
System.out.println();
System.out.print("Store
5:");
for
(int i=0; i<sales5; i+=100)
{
System.out.print("*");
}
}
}
_________________________________________________________________________________
Rectangle Area
getLength — This method should ask the user to enter the rectangle’s length, and then return that value as a double.
• getWidth — This method should ask the user to enter the rectangle’s width, and then return that value as a double.
• getArea — This method should accept the rectangle’s length and width as argu-ments, and return the rectangle’s area. The area is calculated by multiplying the length by the width.
• displayData — This method should accept the rectangle’s length, width, and area as arguments, and display them in an appropriate message on the screen.
/** To change this template, choose Tools | Templates* and open the template in the editor.*/import javax.swing.JOptionPane;package areaofrectriangle;/**** @author k305*/public class AreaOfrectriangle {/*** @param args the command line arguments*/public static void main(String[] args){double length; // The rectangle's lengthdouble width; // The rectangle's widthdouble area; // The rectangle's arealength = getLength();width = getWidth();area = getArea(length, width);displayData(length, width, area);System.exit(0);}public static double getLength(){String input; // To hold keyboard inputinput = JOptionPane.showInputDialog("Enter the rectangle's length.");return Double.parseDouble(input);}public static double getWidth(){String input; // To hold keyboard inputinput = JOptionPane.showInputDialog("Enter the rectangle's width.");return Double.parseDouble(input);}public static double getArea(double length, double width){return length * width;}public static void displayData(double length, double width,double area){JOptionPane.showMessageDialog(null, "The length is " +length +", the width is " + width +" and the area is " + area + ".");}}______________________________________________________________
Design a Payroll
class that has fields for an employee's name, ID number, hourly pay
rate, and number of hours worked. Write the appropriate accessor and
mutator methods and a constructor that accepts the employee's name and
ID number as arguments. The class should also have a methods that
returns the employee's gross pay, which is calculated as the number of
hours worked multiplied by the hourly pay rate. Write a program that
demonstrates the class by creating a Payroll object, then asking the user to enter the data for an employee. The program should display the amount of gross pay earned.
In this exercise, you need only provide the definition of the Payroll class. The demonstration class (PayrollDemo) is provided for you. Accessor and mutator methods for the name, idNumber, hoursWorked, and payRate attributes should follow the standard naming conventions introduced in the chapter (e.g., getIdNumber and setIdNumber). The method that returns the employee's gross pay should be named getGrossPay.
/**
* Class to represent
the payroll for an employee
*
* @JaziGarcia
*/
public class Payroll
{
public String
name;
public String id;
public double
hoursWorked;
public double
payRate;
/**
* Constructor for
objects of class Payroll
*/
public
Payroll(String newName, String newID) {
name =
newName;
id = newID;
}
public String
getName() {
return name;
}
public String
getID() {
return id;
}
public void
setHoursWorked(double hours) {
hoursWorked =
hours;
}
public double
getHoursWorked() {
return
hoursWorked;
}
public void
setPayRate(double rate) {
payRate =
rate;
}
public double
getPayRate() {
return
payRate;
}
public double
getGrossPay() {
return
hoursWorked*payRate;
}
}
No comments:
Post a Comment