Question

In: Computer Science

This is all that was given. Write a program in a PL of your choice to...

This is all that was given.

Write a program in a PL of your choice to create the followings Output:

A table(7 rows), you see below, showing 35 names grouped in 7 lines.
The first column is the chosen Programming Language to develop and present by the group.

PLs All group Names

C n26 n06 n28 n16 n30
C++ n31 n07 n33 n17 n35
C# n03 n08 n13 n18 n23
Python n04 n09 n14 n19 n24
java n05 n10 n15 n20 n25
JS n01 n27 n11 n29 n21
Ruby n02 n32 n12 n34 n22
Do you need more ? <0,1>1

PLs All group Names

C n01 n31 n11 n04 n21
C++ n02 n07 n12 n09 n22
C# n28 n33 n13 n14 n15
Python n16 n17 n18 n19 n20
java n30 n35 n23 n24 n25
JS n26 n27 n03 n29 n05
Ruby n06 n32 n08 n34 n10
Do you need more ? <0,1>0

- Names are unique, they should not be duplicated as this (nam7, name7), they can be real student names.

- The program should allow the user to rearrange the students and the groups at will.
Example: select many students in one of several groups :  

if(( student_numbers %7) ==0 ) set student in group 1 (first group), and

if ((student_numbers %7) ==1 ) in group 2 (second group)

if ((student_numbers %7) ==2 ) in group 3 (third group)

if ((student_numbers %7) ==3 ) in group 4 (fourth group)

if (((student_numbers %7) ==4) in group 5 (fifth group)

if ((student_numbers %7 )==5) in group 6 (sixth group)

if ((student_numbers %7) ==6) in group 7 (seventh group)


Note: here % modulo function was used, but we can use other methods of classification (formula, or function like).

Assignment: (Write a program in any PL and submit. (Required for grading))

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

Here is a pdf (repeated copy):

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

Write a program in a PL of your choice to create the followings Output:
A table (7 rows), you see below, showing 35 names grouped in 7 lines.
The first column is the chosen Programming Language to develop and present by the group.

- Names are unique, they should not be duplicated as this (nam7, name7), they can be real
student names.
- The program should allow the user to rearrange the students and the groups at will.
Example: select many students in one of several groups:
If (( student_numbers %7) ==0) set student in group 1 (first group), and
if ((student_numbers %7) ==1) in group 2 (second group)
if ((student_numbers %7) ==2) in group 3 (third group)
if ((student_numbers %7) ==3) in group 4 (fourth group)
if (((student_numbers %7) ==4) in group 5 (fifth group)
if ((student_numbers %7) ==5) in group 6 (sixth group)
if ((student_numbers %7) ==6) in group 7 (seventh group)
Note: here % modulo function was used, but we can use other methods of classification
(formula, or function like).

Assignment: (Write a program in any PL and submit. (Required for grading))
Input: list of PLs, and list of student names (generate these at random)
Output: the given Table (format) you see above

Solutions

Expert Solution

import random

# function to generate random students
def generate():
    l=[]
    ll=[]
    
    c=0
    while c<35:
        a=random.randint(1,35)
        while a in l:
            a=random.randint(1,35)
        l.append(a)
        ll.append(a)
        if(len(ll)==5):
            students1.append(ll)# list of group of 5 students
            ll=[]
        students.append(a)# list of all random generated students
        c=c+1

# function to rearrange students in groups 
def rearrange():
    l=[]
    l1=[]
    l2=[]
    l3=[]
    l4=[]
    l5=[]
    l6=[]
    
    # rearrange students in each group
    for i in students:
        if i%7==0:# group 1
            l.append(i)
        elif i%7==1:# group 2
            l1.append(i)
        elif i%7==2:# group 3
            l2.append(i)
        elif i%7==3:# group 4
            l3.append(i)
        elif i%7==4:# group 5
            l4.append(i)
        elif i%7==5:# group 6
            l5.append(i)
        else:# group 7
            l6.append(i)
    students2.append(l)
    students2.append(l1)
    students2.append(l2)
    students2.append(l3)
    students2.append(l4)
    students2.append(l5)
    students2.append(l6)

#function to display PL and students group wise
def display(l):
    c=0
    for i in l:
        print(pl[c],end=' ')
        c=c+1
        for j in i:
            s='n'+str(j)
            print(s,end=' ')
        print()

# list of PLs
pl=['C','C++','C#','Python','Java','JS','Ruby']
students=[]
students1=[]

# list to store rearranged list of list of students
students2=[]
n=1

while n==1:
    students=[]
    students1=[]
    students2=[]
    
    generate()
    flag=int(input("Do you want to rearrange students and groups? <0,1> "))
    print('PLs All group Names')
    if flag==1:# if user asks to rearrange
        rearrange()
        display(students2)
    else:
        display(students1)
    n=int(input("Do you need more ? <0,1> "))
    


Related Solutions

Write a program (your choice!) that fulfills all the requirements below. The final product should include...
Write a program (your choice!) that fulfills all the requirements below. The final product should include the pseudocode and flowchart for the entire program. Variables of each data type String, Integer, Real, Boolean Must contain at least one type of calculation Minimum of 3 modules/functions At least 2 decision structures IF, IF-ELSE, IF-ELSE IF At least 1 type of loop WHILE or FOR At least 1 array/list
Write a program in a language of your choice to perform a search using the A*...
Write a program in a language of your choice to perform a search using the A* algorithm for the eight puzzle problem, in which numbers may be shifted one space at a time to transform the initial state into the goal state (see p. 103 – 3rd Ed., pp. 105-106 – 2nd Ed. of the text). 2. a) Use the start state-goal state combination given in pp. 103, Figure 3.28 (3rd Ed.), [pp. 105, Figure 4.7 (2rd Ed.)], as (start_1,...
write a C++ program to CREATE A CLASS EMPLOYEE WITH YOUR CHOICE OF ATTRIBUTES AND FUNCTIONS...
write a C++ program to CREATE A CLASS EMPLOYEE WITH YOUR CHOICE OF ATTRIBUTES AND FUNCTIONS COVERING THE FOLLOWING POINTS: 1) COUNTING NUMBER OF OBJECTS CREATED ( NO OBJECT ARRAY TO BE USED) USING ROLE OF STATIC MEMBER 2) SHOWING THE VALID INVALID STATEMENTS IN CASE OF STATIC MEMBER WITH NON STATIC MEMBER FUNCTION, NON STATIC MEMBERS OF CLASS WITH STATIC MEMBER FUNCTION, BOTH STATIC. SHOW THE ERRORS WHERE STATEMENTS ARE INVALID. 3) CALL OF STATIC MEMBER FUNCTION, DECLARATION OF...
Write the simplest program possible in your language of choice containing your 'main' and any other...
Write the simplest program possible in your language of choice containing your 'main' and any other functions you may need that will: A. Read a sequence of words up to a maximum of 64 words from std input. Before reading the input, prompt the user to enter the words. B. Check to see if there any duplicate words in the input read. C. If there are no duplicates, print out to std output the message 'No Duplicates'. D. If there...
Write a C++ program that summarizes all of the Oscars that a given actor or movie...
Write a C++ program that summarizes all of the Oscars that a given actor or movie has won or been nominated for. You have been provided with a CSV file with all of the Oscar wins and nominations below. Each row of this file contains 4 pieces of information, separated by commas: the year, the award category, whether they won the award (TRUE or FALSE), and the recipient. Note that the award category and the year may have multiple words...
Using a programming language of your choice, write a complete and fully functional program that uses...
Using a programming language of your choice, write a complete and fully functional program that uses reference and pointer types to swap two double precision floating-point numbers. The two numbers are read in by the program’s user. Use a proper prompt for each number. Use one function that uses formal parameter reference types to swap the two numbers Use another function that uses formal parameter pointer types to swap the two numbers. In the main or driver function, call these...
PL/SQL Write a PL/SQL block, using a While Loop, to calculate and print the sum of...
PL/SQL Write a PL/SQL block, using a While Loop, to calculate and print the sum of the odd integers from 10 to 120 inclusive. (Hint: 11 + 13 + 15 + . . . + 97 + 99)
Please write an anonymous PL/SQL program which uses an implicit cursor to print out the score...
Please write an anonymous PL/SQL program which uses an implicit cursor to print out the score and rank of team 'Mad Scientists' in the competition 'Science Olympiad Regional Baltimore'. Please handle exceptions. Problem 4: [15 points] Please write an anonymous PL/SQL program to print out the names of students and their school names for the team that won the first place (rank=1) in Science Olympiad Maryland State (name of a competition). drop table school cascade constraints; drop table student cascade...
write a java program to Translate or Encrypt the given string : (input char is all...
write a java program to Translate or Encrypt the given string : (input char is all in capital letters) { 15 } *) Each character replaced by new character based on its position value in english alphabet. As A is position is 1, and Z is position 26. *) New characters will be formed after skipping the N (position value MOD 10) char forward. A->A+1= B , B->B+2=D ,C->C+3=F, .... Y->Y+(25%10)->Y+5=D A B C D E F G H I...
Write a program that displays all the cars in the given file (no sorting). Each car...
Write a program that displays all the cars in the given file (no sorting). Each car property is separated by a tab character: \t Given file: cars.txt make model year Ford Expedition 2003 Mazda B-Series 1989 Ford Freestar 2003 Hyundai Elantra 2001 Hyundai Entourage 2008 Chevrolet Camaro 2011 Chevrolet Monte Carlo 2006 Chevrolet Blazer 1996 Chevrolet Aveo 2005 Chevrolet Corvette 1999 Mercedes-Benz E-Class 2006 Dodge Avenger 1995 Pontiac Grand Prix 1973 Mitsubishi Outlander 2011 MINI Clubman 2011 Suzuki Aerio 2007...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT