Skip to content

Programming by Design

If you're not prepared to be wrong, you'll never come up with anything original. – Sir Ken Robinson

  • About
  • Java-PbD
  • C-PbD
  • ASM-PbD
  • Algorithms
  • Other

new code

Posted on July 5, 2019January 11, 2021 By William Jojo
Uncategorized
import java.util.*;

// Class definition
public class methods
{
  // Scanner class for read user input.
  static Scanner kb = new Scanner(System.in);
  
  // main method. This is where it all starts.
  public static void main(String[] args)
  {
    // Declaraions - variables
    double x, y, square;
    
    // Output statements in the form of method calls to println.
    System.out.println("\nThis program uses pow to demonstrate");
    System.out.println("static methods. It will also find");
    System.out.println("the min and max of the two values");
    System.out.println("you have entered.\n");
    
    // prompt the user and read their input 
    System.out.print("Enter a value for x: ");
    x = kb.nextDouble();
    
    // Do it again.
    System.out.print("Enter a value for y: ");
    y = kb.nextDouble();
    
    // Display some results
    System.out.println("The value of x raised to the y is " + Math.pow(x,y));
    
    System.out.println("The min value is " + Math.min(x,y));
    System.out.println("The max value is " + Math.max(x,y));
    
  } // end of the main method
} // end of the class definition

Example code: DOes something

Yeah!


Poop

Post navigation

❮ Previous Post: Chapter 1 – The C Environment
Next Post: Java Exercise Answers ❯

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Copyright © 2018 – 2025 Programming by Design.