1. Use a for or while loop to assign ID numbers for each student. To make it simple, ID numbers should range from 1 to 18.
2. .Write another loop with if-statement(s) nested inside, to place the students from Problem 1 into 6 groups of three (e.g. Students with ID numbers 1,7 and 13 go into one group, ID numbers 2,8 and 14 go into a second group, etc.).
3.
Write a function that outputs the area of a geometric shape. The function should accept three variables. The first variable tells you whether the shape is a triangle or rectangle, the second variable tells you the height of the shape and the third variable tells you the base of the shape.
The output should look something like:
> ZC_Shape_Area("Tri",10,3)
[1] "Area = 15"
>
Can you please provide solution in R programming.
Here are the answers for your questions in R Programming Language.
Kindly upvote if you find the answer helpful.
Question No. 1
NOTE : I have used a vector to assign student id's, each element in the vector represents each student's ID.
CODE :
#Create an empty vector to store student Id's #For loop that loops for 18 times #Assigns value of i to vector each time #prints the id's of students |
SCREENSHOTS :
Please see the screenshots of the code below for the indentations of the code.
OUTPUT :
Question No. 2:
NOTE : This code is continuation of question no.1's code
CODE :
#Create an empty vector to store student Id's #For loop that loops for 18 times #Assigns value of i to vector each time #prints the id's of students #Vector that stores groups of students #for loop that loops for 6 times #print groups |
SCREENSHOTS :
OUTPUT :
Question No. 3
CODE :
#Function with name
ZC_Shape_Area #That takes 3 parameters name and two dimension values ZC_Shape_Area = function(name, x, y){ #if the name is equal to 'Tri' if(all(name == "Tri")){ #Prints area of triangle cat("Area = ",(x*y)/2) } #if the name is equal to 'Rect' else if(all(name == "Rect")){ #Prints area of triangle cat("Area = ",(x*y)) } #if the name is neither 'Rect' nor 'Tri' else{ #Prints the shape is invalid print("Invalid shape name") } } #Function call ZC_Shape_Area("Tri",10,3) |
SCREENSHOTS :
Please see the screenshots of the code below for the indentations of the code.
OUTPUT :
Any doubts regarding this can be explained with pleasure :)
1. Use a for or while loop to assign ID numbers for each student. To make...
1) Given two positive numbers, write a program using while loop to determine their lowest common multiple. You cannot use any automatic LCM, GCD finder function or return command. Program Inputs • Enter the first number: – The user can enter any positive whole number, no error checking required • Enter the second number: – The user can enter any positive whole number, no error checking required Program Outputs • The LCM of X and Y is Z! – Replace...
Objectives:
Use the while loop in a program
Use the do-while loop in a second program
Use the for loop in a third program
Instructions:
Part A. Code a for loop to print the Celsius temperatures for
Fahrenheit temperatures 25 to 125. C = 5/9(F – 32).Output should be
in a table format:
Fahrenheit Celsius
25 ?
. .
. . . .
. .
Turn in the source and the output from Part A.
Part B. Code a while...
We
should use “Java” language. Java Eclipse :)
Fall 2019 1. Assign each line to a variable and write the passage from Shakespeare's Sonnet #52 to console (Careful about line breaking): Blessed are you whose worthiness gives scope, Being had, to triumph; being lacked, to hope. 2. Create two integer variable, width and height. Write them to console in similar format, i.e. Width of rectangle is 5. 3. Update width and height variable with another value, and write them to...
PLEASE USE WHILE LOOP (NOT FOR LOOPS). Python programming. In this problem, you should write one function named multiply. This function should accept one parameter, which you can assume will be a list with one or more integers in it. (If you don’t know what I mean when I say “list of integers”, go do the reading!) The function should loop through all of the numbers in the list, and multiply all of the numbers together. It should return the...
*Python* INTRODUCTION: The goal of this programming assignment is to enable the student to practice object-oriented programming using classes to create objects. PROBLEM DEFINITION: Write a class named Employee that holds the following data about an employee in attributes: name, IDnumber, department, jobTitle The class should have 8 methods as follows: For each attribute, there should be a method that takes a parameter to be assigned to the attribute. This is known as a mutator method. For each...
1- Write a program to read 10 numbers and find the average of these numbers. Use a while loop to read these numbers and keep track of input numbers read. Terminate the while loop with a sentinel value. 2- Now modify the program to find the maximum of these numbers as well. The program should print the number of elements read as input and run until -1 is entered. (-1 is the sentinel that terminates the loop and the program)...
Using C++ 1. Create a while loop that counts even numbers from 2 to 10 2. Create a for loop that counts by five (i.e. 0, 5, 10, ...) from 0 to 100 3. Ask for a person's age and give them three tries to give you a correct age (between 0 and 100) 4. Use a for loop to list Celsius and Fahrenheit temperatures. The "C" should be from -20 to 20 and the F should be shown correspondingly...
Python 3: Please follow the respective rubric
for the following function definition.
Rubric:
Rectangle Shape You should implement the following functions to print a rectangle shape. • print_rectangle(length, width, fillChar, hollow). This function will use draw_shape_line() function to print a rectangle shape with the given length and width, If the hollow is true, the shape will be hollow rectangle, otherwise a filled rectangle. This function must not interact with the user. For example, the call print_rectangle(5, 10, '*', False) should...
Piggy back on the programming project one you completed in module 3. You will use some of those concepts here again. We will be building this project inside out, start individual quiz and use a for loop to repeat it three times for three students. In this program you will be required to write a python program that generates math quizzes for students in second grade. Your program should do the following Ask the student for their name Provide 3...
1) Translate the following equation into a Python assignment statement 2) Write Python code that prints PLUS, MINUS, O ZERO, depending on the value stored in a variable named N. 3) What is printed by: 3 - 1 while 5: while 10 Print ) Page 1 of 9 4) Write a Python while loop that reads in integers until the user enters a negative number, then prints the sum of the numbers. 1-2 of 9 4) Write a Python while...