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

    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

    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
  • Powerful Essays

    The two readings Band of Brothers and A Message to Garcia, were insightful into what it takes to be a good Soldier, and leader. The underlying theme of Band of Brothers is that of brotherhood, hard work, and the importance of doing what needs to be done regardless of how difficult it maybe. While A Message to Garcia, brings up of the importance of work ethic and how that is an uncommon trait that everyone values but few have. Both texts tell how the importance of discipline, focus, and the courage it takes to over-come overwhelming odds. They both speak about life lessons that will guide me towards what I hope to accomplish and become over my military career.…

    • 2787 Words
    • 12 Pages
    Powerful 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
  • Powerful Essays

    We all know that today we are living in a ‘Global Village’; it means the smallest changes in the economy of any area in the world will affect, although small, on the global economy. In the past 50 years, the world economy has grown continuously except in the Great Recession Period, which saw a slight reduction in real global GDP. Globalization provides a significant benefit to each economy around the world, by making markets more productive, increasing competition and spreading wealth more equally around the world. This means more people in the world and of course, Canada has a better financial situation and become richer and has more power to invest in real estate. Below, we are reviewing some of the key factors which affecting the Canadian…

    • 1439 Words
    • 6 Pages
    Powerful Essays
  • Good Essays

    We the people. Three courageous words that set the newly American people on a mission. A mission for life, a mission for liberty, and a mission for happiness. But those noble ideals embodied in the Declaration of Independence, Constitution, and Bill of Rights are still far from being achieved, and the mission continues to this day. Freedom for America didn't free the slaves, give women the right to vote, or end religious prejudice. There is nothing about a law that makes it inherently just, and the US is no exception. As a result of this, citizens may at times come to the conclusion that certain laws are in need of changing. The intention of the documents that set up our democracy was to ensure the government would forever be by and for the people. Sometimes legal means for ensuring America stays true to its original purpose prove inadequate. If such is the case in the instance at hand, turning to civil disobedience can have a positive impact on a free society.…

    • 799 Words
    • 4 Pages
    Good 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
  • 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
  • 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
  • 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
  • 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

Related Topics