วันอาทิตย์ที่ 6 กันยายน พ.ศ. 2558

WEEK2
PROJECT 3-2
Write a program that takes the radius of a sphere (a double) as input and outputs the sphere’s diameter, circumference, surface area, and volume.
ANS.
/*
   COMPLETE SCHOOL NAME: BURAPHA UNIVERSITY
           COURSE TITLE: JAVA PROGRAMMING
            COURSE CODE: 958307
*/
package radius;

/**
*  STUDENT NAME: SUKANDA INSUK
* STUDENT NICKNAME: PIM
* STUDENT NUMBER: 56110029
* COURSE: BIS
* SUBJECT: JAVA PROGRAMMING
* INSTRUCTOR: JOSE SUZUKI SANTOS
* DATE CREATED: 1/9/2015
*/

import java.util.Scanner;

public class Radius {

   /**
    * LESSON NAME: Radius
    */
   public static void main(String[] args) {
   Scanner reader = new Scanner(System.in);
   double radius;
   double diameter;
   double circumference;
   double surfacearea;
   
   //Request the inputs
   System.out.print("Enter the radius of a sphere : ");
   radius = reader.nextDouble();
   
   //Computer
   diameter = 2 * radius;
   circumference = 2 * (3.14 * radius);
   surfacearea = 3.14 * (radius * radius);
   

   //Display
   System.out.println("The sphere’s diameter " + diameter);
   System.out.println("The sphere’s circumference " + circumference);
   System.out.println("The sphere’s surface area " + surfacearea);
                       
   }
   
}

= When you input number the radius of a sphereas, it will calculator outputs the sphere’s diameter, circumference and surface area.
+++++++++++++++++++++++++++++++++++++++++++
PROJECT 3-4
An employee’s total weekly pay equals the hourly wage multiplied by the total number of regular hours plus any overtime pay. Overtime pay equals the total overtime hours multiplied by 1.5 times the hourly wage. Write a program that takes as inputs the hourly wage, total regular hours, and total overtime hours and displays an employee’s total weekly pay.
ANS
/*
   COMPLETE SCHOOL NAME: BURAPHA UNIVERSITY
           COURSE TITLE: JAVA PROGRAMMING
            COURSE CODE: 958307
*/
package hourlywage;

/**
*  STUDENT NAME: SUKANDA INSUK
* STUDENT NICKNAME: PIM
* STUDENT NUMBER: 56110029
* COURSE: BIS
* SUBJECT: JAVA PROGRAMMING
* INSTRUCTOR: JOSE SUZUKI SANTOS
* DATE CREATED: 1/9/2015
*/

import java.util.Scanner;

public class Hourlywage {

   /**
    * LESSON NAME: Hourly wage
    */
   public static void main(String[] args) {
   Scanner reader = new Scanner(System.in);
   double hourlywage;
   double trh;
   double toh;
   double totalweeklypay;
   
   //Request the inputs
   System.out.print("Enter the hourly wage : ");
   hourlywage = reader.nextDouble();
   
   System.out.print("Enter the total regular hours : ");
   trh = reader.nextDouble();
   
   System.out.print("Enter the total overtime hours : ");
   toh = reader.nextDouble();
   
   //Computer
   totalweeklypay = (hourlywage * trh) + (toh * 1.5);

   //Display
   System.out.println("An employee’s total weekly pay  " + totalweeklypay);
   
   }
   
}

= When you input number hourly wage, total regular hours, and  total overtime hours, it will calculator outputs the employee’s total weekly pay.