Need Help With This Assignment?

Let Our Team of Professional Writers Write a PLAGIARISM-FREE Paper for You!

Discussion – Loops and Arrays

Discussion – Loops and Arrays

Write pseudocode for a program that will record weather-related data for any month or months.

  1. Input could be month name(s)
  2. for loop inputs could be:
  3. High and low temperatures
  4. Precipitation

iii. Humidity.

 

Answer:

Pseudocode.

void fun()
{
Int m= number of Months; // number of months input
Input m;

Initialize Array1[m] , Array2[m]
Loop (Initialize i=0 to i<m)
Input Month Name;

Store Array1[i] as Month Name;
Loop(Initialize j=0 to j<m) //input humidity, precipitation or temperature serial wise as name of Month entered
Input Temperature;
Input Precipitation:
Input Humidity;

Store Array2[j] as Temperature, Precipitation, Humidity;

Loop (Initialize k=0 to k<m)

Output Array1[k] , Array2[k]; //will print the Month Name with Temprature, Precipitaion, Humidity

return 0;
}

Summary:

  1. Basically, pseudocode is a high-level algorithm definition that can be applied in any programming language.
  2. The for loop takes the group elements and executes for each element within the loop.
  3. A plant that makes iron profiles has a lot of “n” pieces. Create a program that asks you to enter the quantity of pieces to be processed by keyboard and then enter the length of each profile, knowing that the pieces whose length is in the range of 1.20 and 1.30 are suitable. Print on the screen the number of suitable pieces in the batch.

Answer:

The above problem is solved with Python language.

Code:

def batches ():
print (“Enter the number of pieces: “)
n = Int (input ())
arr = list ()
for i in range (n):
j = float (input(“Enter the element: “))
arr.append (j)

c = 0
for i in range (n):
If (arr[i] > 1.20 and arr [i] < 1.30):
c = c+1;

print (“The number of suitable pieces in the batch are: “, c)

batches()

  1. In a company work n employee whose salaries range between $ 100 and $ 500, create a program that reads the salaries that each employee receives and report how many employees receive between $ 100 and $ 300 and how many receive more than $ 300. In addition, the program must report the amount the company spends in salaries to staff.

Answer:

#reading employees number and declaring variables
n=int (input())
ar=[]
c=0
sal=0
print(“salary ranges between $100 and $500”)
print (“enter salaries”)

for i in range (n):
sal=int (input())
ar.append (sal)
#Check Conditionality
for i in ar:
if 100<=i<=300:
c+=1
#Display Outputs
print (c,” Persons Receives Salary Between $100 and $300″)
print(len(ar)-c,” Persons Receive More Than $300″)
print(“Company Spends in $”,Sum(ar),” Amount in Salaries to Staff”)

  1. Make a program that allows you to load two lists of 15 numbers each. Inform with a message which of the two lists has a greater cumulative value (messages “List 1 major”, “List 2 major”, “Equal lists”).

Answer:

 

def readList (n):
data = []
while len (data) != n:
data. Append (int (input(‘Enter a integer: ‘)))
return data

print (‘Reading First List:’)
a = ReadList(15)
print(‘Reading Second List:’)
b = ReadList(15)

aSum = sum (a)
bSum = sum (b)

if aSum > bSum:
print(‘List 1 Major’)
elif aSum < bSum:
print(‘List 2 Major’)
else:
print(‘Equal Lists’)

  1. It is intended to read all the employees of a company – located in a COMPANY file – and at the end of reading the file, shows the following message: “There are ## workers over 65 years of age ” (## is the number of workers that are over 65 years old).

Answer:

C# language.

// Current Date

var Today = DateTime.Today;

// Ages at a given time calculation

var Age = today. Year – birthdate. Year;

counter = 0

for ()

//snippet

 

if (age > 60)

counter <- counter+1

  1. A weather station provides a couple of daily temperatures (maximum, minimum) (it is not possible for either or both temperatures to be 9 degrees). The end temperature pair is 0, 0. Create a program that determines the number of days, whose temperatures have been provided, the maximum and minimum averages, the number of errors – temperatures of 9 ° – and the percentage they represented.

Answer:

c# language

Using System;

Namespace Tem {

Class Myapplication {

public static void Main () {

Int n, m, k=1;

for (i=1; i<=k; i++)

{

Console.WriteLine(“Enter the Couple of Daily Temperature:”);

Console.ReadLine(n, m);

If (n! =9&&m! =9)

k=(n+m)/2;

}

Console.WriteLine(“The Number of Days:”);

Console.ReadLine (k);

}

}

}

 

  1. Write the pseudocode to produce a bill for cell phone charges. Data fields will include date, number called, number of minutes, and cost (rate × minutes). Data should be loaded into an array. Include totals for the number of minutes and cost.

Answer:

Calculate-Phone_Bill

Begin

Int date [n] , number_called [n] , min[n] , cost [n]

Int n, Rate, TotalCost, TotalMin

Print (“Enter Total # of Entries in Data:”)

Accept n from User

Print (“Enter Rate of Call for Per Min:”)

Accept Rate from User

For i = 0 to n-1:

Begin

Accept Date in Date=[i]

Accept Number in Number_Call[i]

Accept No_of_minutes in Min [i]

Calculate Cost [i] = Min[i] * Rate

Load it into Cost [i]

End for

For i = 0 to n-1:

TotalCost = TotalCost + Cost [i]

TotalMin = TotalMin + min[i]

End for

Print (” Total Minutes:”, TotalMin)

Print (“Total Cost:”, TotalCost)

End

  1. Each student of a degree in Computer Science has grades corresponding to eight different subjects and may not have a grade in any subject. Each subject corresponds to a certain coefficient. Write a pseudocode to calculate the average of each student.
  2. Modify the algorithm to obtain the following means:
  3. class general
  4. of the class in each subject

iii. Percentage of absences (not submitted for examination)

Answer:

Algorithm.

Each participant obtains a leaflet with each leaflet bear the letters A, B, C or F.

First we write an algorithm to read a notebook and usually print the grade:

  • Take a notebook and read it.
  • Print the Grade.
  • Halt.

We are now writing an algorithm for reading and printing the grade if the grade is A only:

  • Take a notebook and read it.
  • Print the grade if the grade is A.
  • Nothing like that is printed.
  • Halt.

We now write an algorithm to read a notebook and print it if the grade A or B is the only grade:

  • Take a notebook and read it.
  • Just print the grade if grade A or B.
  • Halt.

Pseudocode.

  • Set Total to Zero.
  • Set Grade Counter to One.
  • While Grade Counter is Less Than or Equal to Ten.
  • Input the Next Grade.
  • Add the Grade into the Total Set the Class Average to the Total Divided by Ten.
  • Print the Class Average.
  1. An airplane has one hundred and eighty seats, of which sixty are “non-smokers” and numbered from 1 to 60 and one hundred and twenty seats numbered from 61 to 180 “smoker”. Design a pseudocode that allows the reservation of seats on the plane and stops half an hour before the departure of the plane, at which time the waiting list will open.

 

Answer:

define Array Non-smoker []

define Array Smoker []

define Array Waiting []

book-seat () {

if Current Time + 30 minutes <= Departure Time {

if Passenger is Non-smoker {

if Array Non-smoker []! = full

insert passenger id into Array Non-smoker []

else

print “Sorry, nonsmoker seat not available”

}

if Passenger is Smoker {

if Array Smoker []! = full

insert Passenger id into array Smoker []

else

print “Sorry, Smoker seat not available”

}

}

else {

insert Passenger id into Array Waiting []

}

}

 

  1. Given the name of a series of students and the grades obtained on an exam, calculate and print the average grade, as well as each grade and the difference with the average.

 

 

import java.util.Scanner;

 

public class JavaGrades

{

public static void main(String args[])

{

 

int marks [] = new int[6];

int i;

float total=0, avg;

Scanner scanner = new Scanner(System.in);

 

 

for (i=0; i<6; i++) {

System.out.print(“Enter marks of subject”+(i+1)+”:”);

marks[i] = scanner.nextInt();

total = total + marks[i];

}

scanner.close();

 

 

avg = total/6;

System.out.print(“The student Grade is: “);

if(avg>=80)

{

System.out.print(“A”);

}

else if(avg>=60 && avg<80)

{

System.out.print(“B”);

}

else if(avg>=40 && avg<60)

{

System.out.print(“C”);

}

else

{

System.out.print(“D”);

}

}

}

ORDER A PLAGIARISM-FREE PAPER HERE

We’ll write everything from scratch

Question 


Overview:
In this assignment, you will be analyzing how to use a loop control variable, create nested loops, avoid common loop mistakes, use constants with arrays, search an array for an exact match, and use parallel arrays.

Discussion - Loops and Arrays

Discussion – Loops and Arrays

Instructions: Complete the following programming exercises:
1. Write pseudocode for a program that will record weather-related data for any month or month. a. Input could be month name(s) b. For loop inputs, it could be i. High and low temperatures ii. Precipitation iii. Humidity
2. A plant that makes iron profiles has a lot of “n” pieces. Create a program that asks you to enter the number of pieces to be processed by keyboard and then enter the length of each profile, knowing that the pieces whose length is in the range of 1.20 and 1.30 are suitable. Print on the screen the number of suitable pieces in the batch.
3. In a company that works with employees whose salaries range between $ 100 and $ 500, create a program that reads the salaries that each employee receives and reports how many employees receive between $ 100 and $ 300 and how many receive more than $ 300. In addition, the program must report the amount the company spends on salaries to staff.
4. Make a program that allows you to load two lists of 15 numbers each. Inform with a message which of the two lists has a greater cumulative value (messages “List 1 major”, “List 2 major”, “Equal lists”). CIS216 – Programming Principles Loops and Arrays
5. It is intended to read all the employees of a company – located in a COMPANY file – and, at the end of reading the file, shows the following message: “There are ## workers over 65 years of age” (## is the number of workers that are over 65 years old).
6. A weather station provides a couple of daily temperatures (maximum, minimum) (it is not possible for either or both temperatures to be 9 degrees). The end temperature pair is 0, 0. Create a program that determines the number of days whose temperatures have been provided, the maximum and minimum averages, the number of errors – temperatures of 9 ° – and the percentage they represented.
7. Write the pseudocode to produce a bill for cell phone charges. Data fields will include date, number called, number of minutes, and cost (rate × minutes). Data should be loaded into an array. Include totals for the number of minutes and cost.
8. Each student with a degree in Computer Science has grades corresponding to eight different subjects and may not have a grade in any subject. Each subject corresponds to a certain coefficient. Write a pseudocode to calculate the average of each student. a. Modify the algorithm to obtain the following means: i. class general ii. of the class in each subject iii. Percentage of absences (not submitted for examination)
9. An airplane has one hundred and eighty seats, of which sixty are “non-smokers” and numbered from 1 to 60 and one hundred and twenty seats numbered from 61 to 180 “smoker”. Design a pseudocode that allows the reservation of seats on the plane and stops half an hour before the departure of the plane, at which time the waiting list will open.
10. Given the name of a series of students and the grades obtained on an exam, calculate and print the average grade, as well as each grade and the difference with the average. Requirements:
• Show your work in a Word document. Include all your work for each question. You can include screenshots of work done on paper.
• For all justification exercises, remember to use the definitions and principles that we have learned thus far.
• You must prepare a written work where you respond to the programming exercises. The work must comply with APA academic writing standards. You must support your answer using appropriate sources that are properly cited.