Preview

Assignment

Satisfactory Essays
Open Document
Open Document
1642 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Assignment
| Object–Oriented Programming | Assignment | | Nadhirah Binti Md Rafidi | |

HNDC 12/02 GROUP 2 |

Question 1 import javax.swing.JOptionPane; public class Question1 { final static double PI = 3.14159; public static void main(String[] args) { double radius, area, diameter, circumference; String str = ""; radius = Double.parseDouble(JOptionPane.showInputDialog("Enter the number of radius: ")); area = radius * radius * PI; diameter = 2 * radius; circumference = 2 * PI * radius; JOptionPane.showMessageDialog(null, str + String.format("The area for the circle of radius " + radius + " is " +area)); JOptionPane.showMessageDialog(null, str + String.format("The diameter for the circle of radius " + radius + " is " +diameter)); JOptionPane.showMessageDialog(null, str + String.format("The circumference for the circle of radius " + radius + " is " + circumference)); } }

The Output

Question 2 import javax.swing.JOptionPane; public class Question2
{
public static void main( String args[] ) { int number; int digit1; int digit2; int digit3; int digit4; int digit5;
String str = ""; number = Integer.parseInt(JOptionPane.showInputDialog( "Enter five digit integer: " ));

digit1 = number / 10000; digit2 = number % 10000 / 1000; digit3 = number % 10000 % 1000 / 100; digit4 = number % 10000 % 1000 % 100 / 10; digit5 = number % 10000 % 1000 % 100 % 10;

JOptionPane.showMessageDialog(null, String.format("%d %d %d %d %d\n", digit1, digit2, digit3, digit4, digit5 )); }
}

The Output

Question 3 import javax.swing.JOptionPane; public class Question3
{
public static void main(String[] args)
{
int x; x = Integer.parseInt(JOptionPane.showInputDialog("Enter the number whether the number is even or odd: ")); numberinteger(x); } public static void numberinteger(int x){ if(x % 2 == 0)
{
JOptionPane.showMessageDialog(null, "The number is even");
}
else
{

You May Also Find These Documents Helpful

  • Satisfactory Essays

    The Unit Circle Projec

    • 308 Words
    • 2 Pages

    • Using your medium of choice (no garbage cans, food or glitter, please), create a display of the Unit Circle.…

    • 308 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Equation 4 represents the intersection area between two circles whether the circumference of each circle passes through the centre of the other one and vice versa. Equation 5 is used to the area between two circles. With Equation 6, we formulate the difference between a quarter circle area and a half of A1 area.…

    • 88 Words
    • 1 Page
    Satisfactory Essays
  • Satisfactory Essays

    (key verbs) and circle what you are being asked to look for in order to respond to the prompt…

    • 162 Words
    • 1 Page
    Satisfactory Essays
  • Good Essays

    Graphing Round Objects

    • 354 Words
    • 2 Pages

    Take the meter stick and measure the round object at any two points but making sure it goes through it center. Mark this reading as the diameter…

    • 354 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    Assignment

    • 287 Words
    • 2 Pages

    The paper must be at least two pages in length and formatted according to APA style. Cite your resources in text and on the reference page. For information regarding APA samples and tutorials, visit the Ashford Writing Center, within the Learning Resources tab on the left navigation…

    • 287 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Assignment

    • 2491 Words
    • 10 Pages

    for the first packet, R1 = 980 and the RTP timestamp for the n-th packet Rn =…

    • 2491 Words
    • 10 Pages
    Satisfactory Essays
  • Good Essays

    Physics Spring Lab

    • 539 Words
    • 3 Pages

    Radius of String (m) (+/- .05 mm) | 0.5300 | 0.5150 | 0.5800 | 0.5840 | 0.5530 |…

    • 539 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Assignment

    • 589 Words
    • 3 Pages

    • Passed one part, failed one part • Retake only the part you did not pass • Failed both parts • Retake both parts.…

    • 589 Words
    • 3 Pages
    Satisfactory Essays
  • Powerful Essays

    ASSIGNMENT

    • 4382 Words
    • 13 Pages

    Verbal communication includes talking, whispering, shouting etc. It uses words to give an idea, thought or a feeling.…

    • 4382 Words
    • 13 Pages
    Powerful Essays
  • Good Essays

    Assignment

    • 10817 Words
    • 44 Pages

    APPLICATION FOR INDEFINITE LEAVE TO REMAIN IN THE UK AS THE PARTNER OF A PERSON PRESENT AND SETTLED IN THE UK AND A BIOMETRIC IMMIGRATION DOCUMENT…

    • 10817 Words
    • 44 Pages
    Good Essays
  • Satisfactory Essays

    mr angola

    • 329 Words
    • 2 Pages

    That accepts the circle radius from a user, compute area and circumference. Formula Area= π r², circumference = 2* π r.…

    • 329 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Java Calculator CMD

    • 889 Words
    • 4 Pages

    import java.util. *; class pup { public static void main (String [] args) { int a,b,op; int c = 0; Scanner fSC = new Scanner(System.in); System.out.println("Welcome to CMD basic calculator!\n"+"Press ENTER key to continue . . ."); Scanner aKey = new Scanner(System.in); String akeyp = aKey.nextLine(); System.out.println("Enter first number:"); a = fSC.nextInt(); System.out.println("Input operator to be used( Ex. 1):\n"+"1. Addition\n"+"2. Subtraction\n"+"3. Multiplication\n"+"4.…

    • 889 Words
    • 4 Pages
    Satisfactory Essays
  • Better Essays

    inFile.nextInt( ) – gets the next value in the file. This must be an integer or you will get an Input Mismatch Exception . Return data type is int.…

    • 928 Words
    • 10 Pages
    Better Essays
  • Good Essays

    For Loop

    • 534 Words
    • 3 Pages

    Another type of loop you can use in Java is called the while loop. While loops are a lot easier to understand than for loops. Here's what they look like:…

    • 534 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Assignment

    • 315 Words
    • 2 Pages

    From the evidence above, we can conclude that, the primary sector has gradually declined over the past 30 years. The primary cause according to economists, is the decline in most traditional industries such as, fishing fleets and mining, furthermore, it is cheaper to import raw materials from other developing countries than it is to actually produce them in the UK.…

    • 315 Words
    • 2 Pages
    Satisfactory Essays

Related Topics