STIA1113-A191 / Main-Issues

0 stars 3 forks source link

Pseudocode #3

Open zhamri opened 4 years ago

zhamri commented 4 years ago

Instruction

Below is the Pseudocode to calculate the perimeter of a rectangle.

Start  

1. Output "Enter rectangle length: "  
2. Input length   
3. Output "Enter rectangle width: "  
4. Input width   
5. Calculate perimeter = 2 x(length + width)  
6. Output perimeter    

End  

Write a Java program to calculate the perimeter.

Submission

  1. Java source code
  2. Screenshot the output
LeeXiuNiang commented 4 years ago
import java.util.Scanner;

public class Perimeter{

    public static void main(String[] args){

        double length, width;

        Scanner input = new Scanner(System.in);

        System.out.println("Enter rectangle length: ");
        length = input.nextDouble();

        System.out.println("Enter rectangle width: ");
        width = input.nextDouble();

        double perimeter = 2 * (length + width);

        System.out.println("Perimeter = " + perimeter + "cm");

        input.close();
    }
}
Perimeter
fatinshahira commented 4 years ago
import java.util.Scanner;

public class PerimeterOfRec {

    public static void main(String[] args) {

    Scanner scanner = new Scanner(System.in);
    System.out.println("Enter Rectangle Length");
    double length = scanner.nextDouble();

    System.out.println("Enter Rectangle Width");
    double width = scanner.nextDouble();

    //perimeter = 2*(length+width)
    double perimeter = 2*(length+width);
    System.out.println("Perimeter of Rectangle = " + perimeter);

    scanner.close();
    }
 }

ouput

juliney21 commented 4 years ago
import java.util.Scanner;

public class Perimeter{

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        double l, w, per;

        System.out.print("\nEnter rectangle length: ");
        l=sc.nextDouble();

        System.out.print("Enter rectangle width: ");
        w=sc.nextDouble();

        per = 2*(l+w);

        System.out.println("Perimeter: "+ per);
        sc.close();

    }

}

perimeter

ngkerong commented 4 years ago
/*Name:Ng Ke Rong*/
/*Matrik.No:271063*/

import java.util.*;

public class PerimeterOfRectangle{

    public static void main(String[] args){

        Scanner input = new Scanner(System.in);

        /*Input Length of Rectangle*/
        System.out.print("Enter rectangle length\t\t:");
        float length = input.nextFloat();

        /*Input Width of Rectangle*/
        System.out.print("Enter rectangle width\t\t:");
        float width = input.nextFloat();

        /*Output Perimeter of Rectangle*/
        float perimeter = 2*(length+width);
        System.out.println("\nTotal perimeter of rectangle\t:" +perimeter);

        input.close();
    }
}

Rectangle

Chaijiesheng commented 4 years ago
import java.util.Scanner;

public class PerimeterOfARectangle {

    public static void main(String[] args) {
        float lenght,width;

        Scanner input = new Scanner(System.in);
        System.out.println("Enter rectangle length");
        lenght = input.nextFloat();

        System.out.println("Enter rectangle width");
        width = input.nextFloat();

        float perimeter = 2*(lenght+width);

        System.out.println("Perimeter="+perimeter +"cm");

    }
}

image

nasyiqin commented 4 years ago

import java.util.Scanner;

public class HelloWorld{

    public static void main(String [] args) {

        int length;
        int width, perimeter; 

        Scanner input = new Scanner(System.in);

        System.out.println("Enter rectangle length: " );
        length = input.nextInt();
        System.out.println("Enter rectangle width: " );
        width = input.nextInt();

        perimeter = 2 * (length + width);
        System.out.println("Perimeter: " + perimeter);

        input.close();
    }
}

Issue3

Yoncing99 commented 4 years ago
import java.util.Scanner;
public class Perimeter {  

    public static void main (String[]args){
        Scanner p= new Scanner(System.in);

        System.out.println("Enter length of Rectangle:");
        final double l= p.nextDouble(); 

        System.out.println("Enter width of Rectangle:");
        final double w= p.nextDouble();

        final double perimeter  = 2*(l+w); 
        System.out.println("Perimeter of Rectangle= "+perimeter);
        p.close();
    }
}

image

Pyong99 commented 4 years ago
import java.util.Scanner;

public class perimeterofrectangle{
    public static void main(String[]args){
         Scanner in = new Scanner(System.in);

         System.out.println("Enter rectangle length:");
         double length = in.nextDouble();

         System.out.println("Enter rectangle width:");
         double width = in.nextDouble();

         double perimeter = 2*(length + width);
         System.out.print("Perimeter of rectangle=" + perimeter+"cm");

         in.close();
    }
}

pseudocode

kaiting0415 commented 4 years ago
import java.util.Scanner;
public class HelloWorld3{

 public static void main(String[] args){
 Scanner sc = new Scanner (System.in);
System.out.println("Enter rectangle length");
double length =sc.nextDouble();
System.out.println("Enter rectangle width");
double width =sc.nextDouble();
double perimeter =2*(length + width);
System.out.println("perimeter of rectangle=" + perimeter);
 sc.close();
 }
 }

HelloWorld3

wongfangman commented 4 years ago

import java.util.Scanner;

public class perimeterofrectangle{

    public static void main(String[]args){

    Scanner in = new Scanner(System.in);

    System.out.println("Enter the length of the Rectangle:");

    Double l = in.nextDouble();

    System.out.println("Enter the width of the Rectangle:");

    Double w = in.nextDouble();

    Double perimeter = 2 * (l+w);

    System.out.println("Perimeter of Rectangle:" + perimeter);

    in.close();
    }

}
perimeterofrectangle
jannatulafiqah commented 4 years ago
import java.util.Scanner;
public class Perimeter{

    public static void main (String[] args){

        float length, width;
        Scanner input = new Scanner (System.in);

        System.out.println ("enter the length : " );
        length = input.nextFloat();

        System.out.println ("enter the width : " );
         width = input.nextFloat();

        System.out.println ("the perimeter is : " );
        System.out.print (2*(length + width));

        input.close();

    }
}

image

nadnadia25 commented 4 years ago

import java.util.Scanner; public class perimeterex1{

public static void main (String[] args) {

    byte length, width ;
    Scanner input = new Scanner ( System.in);

    System.out.println ("enter the length : ");
    length = input.nextbyte ();

    System.out.println ("enter the width : ");
    width = input.nextbyte ();

    System.out.println ("the perimeter is :");
    System.out.println ( 2* (length + width));
    Scanner.close();

    }    
}

IMG_20191011_135221 (2)