1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kiruha [24]
3 years ago
15

Algorithm and flowchart to find the perimeter and area of square​

Computers and Technology
1 answer:
kupik [55]3 years ago
4 0

Answer:

I can give you the perimeter "algorithm" but not the flowchart.

Here you go:

p = w * 4

p = perimiter,

w = width/height

4 = the amount of sides needed.

perimeter = width * 4

to include both width and height, we would instead use:

perimeter = 2(width+height)

This also works with rectangles ^

--------------------------------------------------------------------------

To find an area, it is just width * height. This is also compatible with rectangles.

You might be interested in
Write a program to compute an employee's weekly pay and produce a pay slip showing name, gross, pay, deductions, and net pay. Th
Umnica [9.8K]

Answer:

# get the employee data

family_name = input("Enter family name: ")

given_name = input("Enter given name: ")

hourly_rate = int(input("Enter hourly rate of pay: "))

hours = int(input("Enter hours worked for the week: "))

tax_cat = input("Enter tax category from a through e: ")

is_charit = input("Do you want to donate $20 to charity y/n: ")

gross_pay = 0

net_pay = 0

deductions = ""

# gross_pay

if hours > 40:

   gross_pay = hours * (2 * hourly_rate)

else:  

   gross_pay = hours * hourly_rate

# net_pay and deduction

if tax_cat == 'a':

   if is_charit == 'y':

       net_pay = gross_pay - 20

       deduction = "$20 charity donation"

   else:

       net_pay = gross_pay

       deduction = "0% tax"

elif tax_cat == 'b':

   if is_charit == 'y':

       net_pay = gross_pay - ( 0.1 * gross_pay) - 20

       deduction = "$20 charity donation and 10% tax"

   else:

       net_pay = gross_pay - (0.1 * gross_pay)

       deduction = "10% tax"

elif tax_cat == 'c':

   if is_charit == 'y':

       net_pay = gross_pay - ( 0.2 * gross_pay) - 20

       deduction = "$20 charity donation and 20% tax"

   else:

       net_pay = gross_pay - (0.2 * gross_pay)

       deduction = "20% tax"

elif tax_cat == 'd':

   if is_charit == 'y':

       net_pay = gross_pay - ( 0.29 * gross_pay) - 20

       deduction = "$20 charity donation and 29% tax"

   else:

       net_pay = gross_pay - (0.29 * gross_pay)

       deduction = "29% tax"

if tax_cat == 'e':

   if is_charit == 'y':

       net_pay = gross_pay - ( 0.35 * gross_pay) - 20

       deduction = "$20 charity donation and 35% tax"

   else:

       net_pay = gross_pay - (0.35 * gross_pay)

       deduction = "35% tax"

# output of the employee's weekly pay.

print(f"Employee name: {given_name} {family_name}")

print(f"Gross pay: ${gross_pay}")

print(f"Net pay: {net_pay}")

print(f"Deductions: {deduction}")

Explanation:

The python program uses the input built-in function to prompt and get user data for the program. The gross pay returns the total pay of the employee without any deduction while net pay returns the pay with all deductions included.

6 0
3 years ago
Create the class named SortFile. The class will have a single attribute, which is an ArrayList of integers. The class will have
S_A_V [24]

Answer:

See explaination

Explanation:

//SortFile.java

import java.io.File;

import java.io.FileNotFoundException;

import java.util.ArrayList;

import java.util.Arrays;

import java.util.Scanner;

public class SortFile {

// array list of integers to store the numbers

private ArrayList<Integer> list;

// default constructor

public SortFile() {

// initializing list

list = new ArrayList<Integer>();

// reading file name using a scanner

Scanner sc = new Scanner(System.in);

System.out.print("Enter file name: ");

String filename = sc.nextLine();

// opening file inside a try catch block. if you want to throw exception

// instead, just remove try-catch block and add throws

// FileNotFoundException to the method signature.

try {

// opening file

sc = new Scanner(new File(filename));

// looping and reading each integer from file to list

while (sc.hasNextInt()) {

list.add(sc.nextInt());

}

// closing file

sc.close();

} catch (FileNotFoundException e) {

// exception occurred.

System.err.println(e);

}

}

// constructor taking a file name

public SortFile(String filename) {

// initializing list

list = new ArrayList<Integer>();

// opening file inside a try catch block. if you want to throw exception

// instead, just remove try-catch block and add throws

// FileNotFoundException to the method signature.

try {

Scanner sc = new Scanner(new File(filename));

// looping and reading each integer from file to list

while (sc.hasNextInt()) {

list.add(sc.nextInt());

}

sc.close();

} catch (FileNotFoundException e) {

System.err.println(e);

}

}

// method to return a sorted array of integers containing unique elements

// from list

public int[] sort() {

// creating an array of list.size() size

int arr[] = new int[list.size()];

// count of unique (non duplicate) numbers

int count = 0;

// looping through the list

for (int i = 0; i < list.size(); i++) {

// fetching element

int element = list.get(i);

// if this element does not appear before on list, adding to arr at

// index=count and incrementing count

if (!list.subList(0, i).contains(element)) {

arr[count++] = element;

}

}

// now reducing the size of arr to count, so that there are no blank

// locations

arr = Arrays.copyOf(arr, count);

// using selection sort algorithm to sort the array

int index = 0;

// loops until index is equal to the array length. i.e the whole array

// is sorted

while (index < arr.length) {

// finding the index of biggest element in unsorted array

// initially assuming index as the index of biggest element

int index_max = index;

// looping through the unsorted part of array

for (int i = index + 1; i < arr.length; i++) {

// if current element is bigger than element at index_max,

// updating index_max

if (arr[i] > arr[index_max]) {

index_max = i;

}

}

// now we simply swap elements at index_max and index

int temp = arr[index_max];

arr[index_max] = arr[index];

arr[index] = temp;

// updating index

index++;

// now elements from 0 to index-1 are sorted. this will continue

// until whole array is sorted

}

//returning sorted array

return arr;

}

//code for test-run

public static void main(String[] args) {

//initializing SortFile using default constructor

SortFile sortFile = new SortFile();

//displaying sorted array

System.out.println(Arrays.toString(sortFile.sort()));

}

6 0
4 years ago
Which header will be the largest?<br><br> Hello<br><br> Hello<br><br> Hello<br><br> Hello
geniusboy [140]

Answer:  

Bye

bye

bye

bye

Explanation:

4 0
3 years ago
Read 2 more answers
CONCEPTO DE ORGANIGRAMA
inysia [295]
Como the amas si mucho gusto
3 0
3 years ago
Task 2 Design a 1st order low-pass filter with cutoff frequency 1kHz, 1) with roll-off and 2) without roll-off. For each filter,
miskamm [114]

You can get complete answer in attached document.please have a look.

Explanation:

(2) Without rolloff, as given fc =1kHz Let us assume it is a first order RC filter ats transfer function is H(s)-RC RC withou

Then the transfer function becom

and step response is flat zero for without rolloff..

6 0
4 years ago
Other questions:
  • What can be used to describe and document the analysis and design of complex software systems?
    14·1 answer
  • Use computer magazines and/or the internet to investigate one of these DBMSs: DB2, SQL Server, MySQL, Oracle, or Sybase. Prepare
    15·1 answer
  • Ar count = 10;
    13·1 answer
  • ETC = 220,000 PV = 25,000 AC = 40,000. What is EAC? What does this calculation tell you?
    5·1 answer
  • Write a program that utilizes a loop to read a set of five floating-point values from user input. Ask the user to enter the valu
    9·1 answer
  • David is selling his art work. He wants to figure out how much he should charge for each painting to make a 20 percent profit. H
    10·1 answer
  • A collection of wiress connecting the CPU with main memory that is used to identify particular location is called
    13·1 answer
  • Subscribe to Markiplier
    15·2 answers
  • This might be a bad question but what is an AMD Radeon 380 series equivalent to
    7·1 answer
  • You are configuring a RAID drive for a Media Streaming Server. Your primary concern is the speed of delivery of the data. This s
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!