Questions
1.) First Question on Class – the class Circle Given the code below, modify it so...

1.) First Question on Class – the class Circle Given the code below, modify it so that it runs. This will require you to add a class declaration and definition for Circle. For the constructor of Circle that takes no arguments, set the radius of the circle to be 10. You are to design the class Circle around the main method. You may NOT modify the body of the main method in anyway, if you do your code WILL NOT BE ACCEPTED, AND WILL BE GRADED AS ALL WRONG. For this question, YOU MUST capture the output of a run of your program and submit it with your source code as your solution. (TIP: the formula to find the area of a Circle is pi times r squared, or PI * r * r).

#include using namespace std;

const float PI = 3.1416; i

nt main() {

Circle c1, c2, c3; c

1.setRadius(1.0);

c3.setRadius(4.5);

Circle circles[] = {c1, c2, c3};

for (int i = 0; i < 3; i++) {

float rad, diam, area;

Circle c = circles[i];

rad = c.getRadius();

diam = c.getDiameter();

area = c.getArea();

cout << "circle " << (i) << " has a radius of: " << rad << ", a diameter of: " << diam << ", and an area of: " << area << endl;

}

return 0;

The language is C++, thanks in advance

In: Computer Science

DO NOT HARD CODE ANYTHING! Write a class that maintains the scores for a game application....

DO NOT HARD CODE ANYTHING!

Write a class that maintains the scores for a game application. Implement the addition and removal function to update the database. The gamescore.txt contains player’ name and score data record fields separated by comma. For Removal function, uses the name field to select record to remove the game score record.

Use the List.java, LList.java, Dlink.java, GameEntry.java and gamescore.txt found below

Read gamescore.txt to initialize the Linked list in sorted order by score.

Important****ASK the user to Remove, Add and update function to the sorted linked list.

Display “Name exist” when add an exist name to the list.

Display “Name does not exist” when remove a name not on the list.

List.java File:

/** Source code example for "A Practical Introduction to Data

Structures and Algorithm Analysis, 3rd Edition (Java)"

by Clifford A. Shaffer

Copyright 2008-2011 by Clifford A. Shaffer

*/

/** List ADT */

public interface List<E>

{

/**

* Remove all contents from the list, so it is once again empty. Client is

* responsible for reclaiming storage used by the list elements.

*/

public void clear();

/**

* Insert an element at the current location. The client must ensure that

* the list's capacity is not exceeded.

*

* @param item

* The element to be inserted.

*/

public void insert(E item);

/**

* Append an element at the end of the list. The client must ensure that

* the list's capacity is not exceeded.

*

* @param item

* The element to be appended.

*/

public void append(E item);

/**

* Remove and return the current element.

*

* @return The element that was removed.

*/

public E remove();

/** Set the current position to the start of the list */

public void moveToStart();

/** Set the current position to the end of the list */

public void moveToEnd();

/**

* Move the current position one step left. No change if already at

* beginning.

*/

public void prev();

/**

* Move the current position one step right. No change if already at end.

*/

public void next();

/** @return The number of elements in the list. */

public int length();

/** @return The position of the current element. */

public int currPos();

/**

* Set current position.

*

* @param pos

* The position to make current.

*/

public void moveToPos(int pos);

/** @return The current element. */

public E getValue();

}

LList.java File:

/**

* Source code example for "A Practical Introduction to Data Structures and

* Algorithm Analysis, 3rd Edition (Java)" by Clifford A. Shaffer Copyright

* 2008-2011 by Clifford A. Shaffer

*/

// Doubly linked list implementation

class LList<E> implements List<E>

{

private DLink<E> head; // Pointer to list header

private DLink<E> tail; // Pointer to last element in list

protected DLink<E> curr; // Pointer ahead of current element

int cnt; // Size of list

// Constructors

LList(int size)

{

this();

} // Ignore size

LList()

{

curr = head = new DLink<E>(null, null); // Create header node

tail = new DLink<E>(head, null);

head.setNext(tail);

cnt = 0;

}

public void clear()

{ // Remove all elements from list

head.setNext(null); // Drop access to rest of links

curr = head = new DLink<E>(null, null); // Create header node

tail = new DLink<E>(head, null);

head.setNext(tail);

cnt = 0;

}

public void moveToStart() // Set curr at list start

{

curr = head;

}

public void moveToEnd() // Set curr at list end

{

curr = tail.prev();

}

/** Insert "it" at current position */

public void insert(E it)

{

curr.setNext(new DLink<E>(it, curr, curr.next()));

curr.next().next().setPrev(curr.next());

cnt++;

}

/** Append "it" to list */

public void append(E it)

{

tail.setPrev(new DLink<E>(it, tail.prev(), tail));

tail.prev().prev().setNext(tail.prev());

cnt++;

}

/** Remove and return current element */

public E remove()

{

if (curr.next() == tail)

return null; // Nothing to remove

E it = curr.next().element(); // Remember value

curr.next().next().setPrev(curr);

curr.setNext(curr.next().next()); // Remove from list

cnt--; // Decrement the count

return it; // Return value removed

}

/** Move curr one step left; no change if at front */

public void prev()

{

if (curr != head) // Can't back up from list head

curr = curr.prev();

}

// Move curr one step right; no change if at end

public void next()

{

if (curr != tail.prev())

curr = curr.next();

}

public int length()

{

return cnt;

}

// Return the position of the current element

public int currPos()

{

DLink<E> temp = head;

int i;

for (i = 0; curr != temp; i++)

temp = temp.next();

return i;

}

// Move down list to "pos" position

public void moveToPos(int pos)

{

assert (pos >= 0) && (pos <= cnt) : "Position out of range";

curr = head;

for (int i = 0; i < pos; i++)

curr = curr.next();

}

public E getValue()

{

// Return current element

if (curr.next() == tail)

return null;

return curr.next().element();

}

// reverseList() method that reverses the LList

public void reverseList()

{

LList<E> revList = new LList<E>();

curr = tail.prev();

while (curr != head)

{

revList.append(curr.element());

curr = curr.prev();

}

head.setNext(revList.head.next());

}

// Extra stuff not printed in the book.

/**

* Generate a human-readable representation of this list's contents that

* looks something like this: < 1 2 3 | 4 5 6 >. The vertical bar

* represents the current location of the fence. This method uses

* toString() on the individual elements.

*

* @return The string representation of this list

*/

public String toString()

{

// Save the current position of the list

int oldPos = currPos();

int length = length();

StringBuffer out = new StringBuffer((length() + 1) * 4);

moveToStart();

out.append("< ");

for (int i = 0; i < oldPos; i++)

{

if (getValue() != null)

{

out.append(getValue());

out.append(" ");

}

next();

}

out.append("| ");

for (int i = oldPos; i < length; i++)

{

out.append(getValue());

out.append(" ");

next();

}

out.append(">");

moveToPos(oldPos); // Reset the fence to its original position

return out.toString();

}

}

DLink.java File:

/** Source code example for "A Practical Introduction to Data

Structures and Algorithm Analysis, 3rd Edition (Java)"

by Clifford A. Shaffer

Copyright 2008-2011 by Clifford A. Shaffer

*/

/** Doubly linked list node */

class DLink<E>

{

private E element; // Value for this node

private DLink<E> next; // Pointer to next node in list

private DLink<E> prev; // Pointer to previous node

/** Constructors */

DLink(E it, DLink<E> p, DLink<E> n)

{

element = it;

prev = p;

next = n;

}

DLink(DLink<E> p, DLink<E> n)

{

prev = p;

next = n;

}

/** Get and set methods for the data members */

DLink<E> next()

{

return next;

}

DLink<E> setNext(DLink<E> nextval)

{

return next = nextval;

}

DLink<E> prev()

{

return prev;

}

DLink<E> setPrev(DLink<E> prevval)

{

return prev = prevval;

}

E element()

{

return element;

}

E setElement(E it)

{

return element = it;

}

}

GameEntry.java File:

public class GameEntry {
protected String name;
protected int score;

public GameEntry(String n, int s) {
name = n;
score = s;
}

public String getName() {return name;}

public int getScore() {return score;}

public String toString() {
return "("+name+","+score+")";
}

}

gamescore.txt File:

Mike,1105
Rob,750
Paul,720
Anna,660
Rose,590
Jack,510

In: Computer Science

Question: In C#: For today's lab you will be creating a store inventory management system. Your...

Question: In C#: For today's lab you will be creating a store inventory management system. Your program will have to have the following elements. It should allow any number of customers to shop at the store using names to identify each one. The user should be able to select which one is the current customer. The system must contain a list of at least 50 items (repeats are allowed) that can be purchased by the customers. For a customer to make a purchase they must transfer the items they wish to buy to their own shopping cart. (A Shopping cart list should be maintained for each customer). The user should be able to switch between customers without losing the contents of each customer's cart. The user can select complete purchase and will be presented with a total for that user’s purchases. Customers should be able to remove items from their cart and return them to the stores inventory. A customer’s cart should be removed after her/his purchase is complete. NOTE: The code structure and guidelines are light because this exercise is designed to test your critical thinking skills and see how you apply the skills you’ve learned throughout the duration of this class.

Use the following guidelines to complete this application:

Classes

Classes should be used to represent Inventory Items

Customers

List(s)

Lists should be used to represent The stores inventory Customers shopping carts

Dictionary

A Dictionary should be used to Track all of the customers - identified by their name

User Options

The user should have the following options:

Select current shopper - list of all shoppers and option to create another shopper

View store inventory - list everything the store is selling

View cart - list of everything in the current Customers cart

Add item to cart - allow the user to select an item to add to the current Customer’s cart and remove it from the store’s inventory. (Can be combined with the View store option if you wish) Remove item from cart - allow the user to select an item to add to the stores inventory and remove it from the current Customer’s cart. (can be combined with the View cart option if you wish)

Complete purchase - Total up the cost of all of the items in the user’s cart and display that value. Remove the customer from the dictionary of customers

Exit - Exit the program

Input

All input should be validated and limited to the options presented to the user The user should not be able to crash the program Program should continue to run until the user chooses to exit File IO

Generate a "receipt" for the customer when they purchase their items.

The receipt contains: Customer name Time of transaction List of items purchased (name & cost) Total cost of items Feel free to add a sub-total and tax (not required). A new receipt file is generated for each completed purchase. Do not overwrite or append to a previous file. The file name: Indicates which customer completed the purchase. What order the receipts were generated. There is more than one good solution to this requirement, do not seek help for this feature - use critical thinking.

In: Computer Science

In order to complete these exercises, you will need to install prolog from swi-prolog.org. Write a...

In order to complete these exercises, you will need to install prolog from swi-prolog.org.

Write a Prolog program by creating a file with you favorite program editor like Notepad++ that contains the following facts:

  • here the predicate parent(X,Y) means X is the parent of Y

  • you can also copy/paste or download the following database from the

    course website

    female(pam). female(liz). female(ann). female(pat). male(tom). male(bob). male(jim). parent(pam,bob). parent(tom,bob). parent(tom,liz). parent(bob,ann). parent(bob,pat). parent(pat,jim).

    (a) Load this file into Prolog, usually this is done with the consult file predicate: ?- consult(‘<filename>’).

    On Windows you can load the fact database with the menu point File®Consult.
    also overloads a bare string list by consulting each item in the list: ['family_tree.pl'].

  • % these are the family facts
    female(pam).
    female(liz).
    female(ann).
    female(pat).
    male(tom).
    male(bob).
    male(jim).
    parent(pam,bob).   % pam is parent of bob (etc.)
    parent(tom,bob).
    parent(tom,liz).
    parent(bob,ann).
    parent(bob,pat).
    parent(pat,jim).

    will work. Once you have loaded the program pose the following queries:

    ?- female(ann).
    ?- female(jim).
    ?- parent(X,bob).
    ?- parent(tom,X).
    ?- parent(X,ann),parent(X,pat).

    What are the answers to these queries? Beware, for some queries here might be more than one answer. To get all the answers type a ';' and carriage return at the question mark.

    (b) Now, using the parent predicate formulate the following Prolog queries:

    1. Who is Pat's parent?
    2. Does Liz have a child?

SWI-Prolog

3. Who is Pat's grandparent?

(c) Given the above facts, extend the program by writing rules defining the following predicates:

sister(X,Y) -- X is the sister of Y.
son(X,Y) -- X is the son of Y.
father(X,Y) -- X is the father of Y. grandmother(X,Y) -- X is the grandmother of Y. ancestor(X,Y) -- X is an ancestor of Y.

(Hint: this predicate might come in handy: different(X,Y):- not(X=Y). Some predicate definitions might be recursive.)

Add these rules to your existing file and attach the file to your submission

Demonstrate that your program works by posing the following queries:

4. ?- sister(X,pat).
5. ?- sister(X,Y).
6. ?- son(jim,X).
7. ?- father(X,bob).
8. ?- grandmother(X,ann). 9. ?- ancestor(X,jim).

Hand in the source code of your prolog program and a proof of the program execution.

For each of parts a, b, and c, you should include screenshots of the relevant contents of the SWI-Prolog console. Part c additionally requires you to attach your .pl file.

In: Computer Science

1+1= ? prove it

1+1= ?
prove it

In: Computer Science

2. A complex number can be expressed as a + bi where a and b are...

2. A complex number can be expressed as a + bi where a and b are real numbers and i is the imaginary unit. The multiplication of two complex numbers is defined as follows:

(a+bi)(c+di) = (ac-bd) + (bc+ad)i

Define a class which represents a complex number. The only member functions you have to define and implement are those which overload the * and *= symbols.

In C++ please, thank you

In: Computer Science

1. Design and implement a class called RandomArray, which has an integer array. The constructor receives...

1. Design and implement a class called RandomArray, which has an integer array. The constructor receives the size of the array to be allocated, then populates the array with random numbers from the range 0 through the size of the array. Methods are required that return the minimum value, maximum value, average value, and a String representation of the array values. Document your design with a UML Class diagram. Create a separate driver class that instantiates a RandomArray object and outputs its contents and the minimum, maximum, and average values.

In: Computer Science

Write an error-free Python program to do the following things. The program should prompt the user...

Write an error-free Python program to do the following things.

  • The program should prompt the user to input a sequence of numbers (say population of states) and then displays the numbers as a bar chart using asterisks.  
  • The numbers must be stored in a list. There will be 6 numbers in total.
  • Write a functionto display the output. The program needs to pass the list of numbers to the function and the output is done in the function.  

Sample output:

Enter population for state 1: 5

Enter population for state 2: 4.5

Enter population for state 3: 3

Enter population for state 4: 7

Enter population for state 5: 6

Enter population for state 6: 2

[5.0, 4.5, 3.0, 7.0, 6.0, 2.0]

Display of list values

* * * * * 5.0

* * * * 4.5

* * * 3.0

* * * * * * * 7.0

* * * * * * 6.0

* * 2.0

In: Computer Science

A Linked List of Integers File IntList.java contains definitions for a linked list of integers. The...

  1. A Linked List of Integers

File IntList.java contains definitions for a linked list of integers. The class contains an inner class IntNode that holds information for a single node in the list (a node has a value and a reference to the next node) and the following IntList methods:

  • public IntList()—constructor; creates an empty list of integers
  • public void addToFront(int val)—takes an integer and puts it on the front of the list
  • public void addToEnd(int val)—takes an integer and puts it on the end of the list
  • public void removeFirst()—removes the first value from the list
  • public void print()—prints the elements in the list from first to last

File IntListTest.java contains a driver that allows you to experiment with these methods. Save both of these files to your directory, compile and run IntListTest, and play around with it to see how it works. Then add the following methods to the IntList class. For each, add an option to the driver to test it.

  1. public int length()—returns the number of elements in the list
  2. public String toString()—returns a String containing the print value of the list.
  3. public void removeLast()—removes the last element of the list. If the list is empty, does nothing.
  4. public void replace(int oldVal, int newVal)—replaces all occurrences of oldVal in the list with newVal.

Note that you can still use the old nodes; just replace the values stored in those nodes.

// ***************************************************************

// FILE: IntList.java

//

// Purpose: Defines a class that represents a list of integers

//

// ***************************************************************

public class IntList

{

private IntNode front; //first node in list

//-----------------------------------------

// Constructor. Initially list is empty.

//-----------------------------------------

public IntList()

{

front = null;

}

//-----------------------------------------

// Adds given integer to front of list.

//-----------------------------------------

public void addToFront(int val)

{

front = new IntNode(val,front);

}

//-----------------------------------------

// Adds given integer to end of list.

//-----------------------------------------

public void addToEnd(int val)

{

IntNode newnode = new IntNode(val,null);

//if list is empty, this will be the only node in it

if (front == null)

front = newnode;

else

{

//make temp point to last thing in list

IntNode temp = front;

while (temp.next != null)

temp = temp.next;

//link new node into list

temp.next = newnode;

}

}

//-----------------------------------------

// Removes the first node from the list.

// If the list is empty, does nothing.

//-----------------------------------------

public void removeFirst()

{

if (front != null)

front = front.next;

}

//------------------------------------------------

// Prints the list elements from first to last.

//------------------------------------------------

public void print()

{

System.out.println("--------------------");

System.out.print("List elements: ");

IntNode temp = front;

while (temp != null)

{

System.out.print(temp.val + " ");

temp = temp.next;

}

System.out.println("\n-----------------------\n");

}

//*************************************************************

// An inner class that represents a node in the integer list.

// The public variables are accessed by the IntList class.

//*************************************************************

private class IntNode

{

public int val; //value stored in node

public IntNode next; //link to next node in list

//------------------------------------------------------------------

// Constructor; sets up the node given a value and IntNode reference

//------------------------------------------------------------------

public IntNode(int val, IntNode next)

{

this.val = val;

this.next = next;

}

}

}

// ***************************************************************

// IntListTest.java

//

// Driver to test IntList methods.

// ***************************************************************

import java.util.Scanner;

public class IntListTest

{

private static Scanner scan;

private static IntList list = new IntList();

//----------------------------------------------------------------

// Creates a list, then repeatedly prints the menu and does what

// the user asks until they quit.

//----------------------------------------------------------------

public static void main(String[] args)

{

scan = new Scanner(System.in);

printMenu();

int choice = scan.nextInt();

while (choice != 0)

{

dispatch(choice);

printMenu();

choice = scan.nextInt();

}

}

//----------------------------------------

// Does what the menu item calls for.

//----------------------------------------

public static void dispatch(int choice)

{

int newVal;

switch(choice)

{

case 0:

System.out.println("Bye!");

break;

case 1: //add to front

System.out.println("Enter integer to add to front");

newVal = scan.nextInt();

list.addToFront(newVal);

break;

case 2: //add to end

System.out.println("Enter integer to add to end");

newVal = scan.nextInt();

list.addToEnd(newVal);

break;

case 3: //remove first element

list.removeFirst();

break;

case 4: //print

list.print();

break;

default:

System.out.println("Sorry, invalid choice")

}

}

//-----------------------------------------

// Prints the user's choices

//-----------------------------------------

public static void printMenu()

{

System.out.println("\n Menu ");

System.out.println(" ====");

System.out.println("0: Quit");

System.out.println("1: Add an integer to the front of the list");

System.out.println("2: Add an integer to the end of the list");

System.out.println("3: Remove an integer from the front of the list");

System.out.println("4: Print the list");

System.out.print("\nEnter your choice: ");

}

}

In: Computer Science

in the pandas_names notebook, write python code to analyze and plot how popular your name is...

in the pandas_names notebook, write python code to analyze and plot how popular your name is compared to one of your family member..

alberto and arturo

if your name is not in the dataset use "penny"as a female name and "ken" as male name.

In: Computer Science

C++ language Using classes (OOD), design a system that will support lending various types of media...

C++ language

Using classes (OOD), design a system that will support lending various types of media starting with books. Program should be able to handle a maximum of 500 books. Program should meet at least the following requirements:

1. Define a base media class with a book class derived from it. (Specific class names determined by programmer.)

2. The classes should contain at least the following information: title, up to four authors, ISBN.

3. Define a collection class that will hold up to 500 books.

4. The program should be able to perform the following operations supported by the class definitions:

a) Load data from a drive

b)Sort and display the books by title

c)Sort and display the books by author

d)Add and remove books

Programming requirements: Must include examples of inheritance and composition

~~~Function/Class comments (Description, pre and post conditions)

~~~Internal comments for all functions

In: Computer Science

Python Program: Description Create an object-oriented program that uses inheritance to perform calculations on a rectangle...

Python Program:

Description
Create an object-oriented program that uses inheritance to perform calculations on a rectangle or a square.

Specifications

  • Use a Rectangle class that provides attributes to store the height and width of a rectangle. This class should also provide methods that calculate the perimeter and area of the rectangle.
  • Use a Square class that inherits the Rectangle class. This class should set the height and the width of the Rectangle superclass to the length that’s set in the Square subclass.
  • The program should determine whether the user wants to enter a rectangle or a square.
  • For a rectangle, the program should get the height and width from the user.
  • For a square, the program should get the length of the square from the user.

Sample Output (Your output should be similar or can be the same to the text in the following box)

Rectangle Calculator
Rectangle or square? (r/s): r
Height: 5
Width: 10
Perimeter: 30
Area: 50

Continue? (y/n): y

Rectangle or square? (r/s): s
Length: 5
Perimeter: 20
Area: 25

Continue? (y/n): n

Thank you for using my app.

In: Computer Science

In Python, Define an object-oriented class to represent a Sensorless Wheeled Robot, including: (a) class data...

In Python, Define an object-oriented class to represent a Sensorless Wheeled Robot, including:

(a) class data variables to store the robot’s x and y position.

(b) A class function or functions to move the robot by one distance unit in either positive or negative x, or positive or negative y dimensions. Include printed, informative output of each move and the resulting robot position

(c) A class function to navigate to the destination location by calling the class move functions (described above) • The destination object is passed in as a parameter to this function. • The obstacle position is also passed as a parameter to the function. • Reaching the destination does not require that the robot is rotated to ’face’ the destination in this model

In: Computer Science

construct flow chart for c program #include <stdio.h> #include <stdlib.h> #include <math.h> void brst(); void thight();...

construct flow chart for c program

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

void brst();
void thight();
void wings();
void back();
void neck();
void menu();
void ex();

float price;
float total;
char choice;
int again;

void main()
{
menu();
}

void menu()
{
char choice = ' ' ;
  
printf("----------------------------------------------------------------------");
printf("\n Welcome to Chicken Chicky Place. \n ");
printf(" && Please select the chicken part that you would like to purchase. && \n\n");
printf(" [A] Breast\n");
printf(" [B] Thigh\n");
printf(" [C] Wings\n");
printf(" [D] Back\n");
printf(" [E] Neck\n");
printf("\n");
printf(" [F] Exit\n\n");
printf("Enter your choice here : ");
scanf("%c", &choice);
printf("----------------------------------------------------------------------");
  
{
if ((choice) == 'A' )
brst();
else
if ((choice) == 'B')
thight();
else
if ((choice) == 'C')
wings();
else
if ((choice) == 'D')
back();
else
if ((choice) == 'E')
neck();
else
if ((choice) == 'F')
ex();
else
if ((choice) != 'A' , 'B' , 'C' , 'D' ,'E', 'F')
{
printf("\n");
system("clear");
menu();
}
}
}
void brst()
{
int choice = 0;
int quantity = 0;
int again = 0;

printf("\n Welcome to Chicken Chicky Place. \n ");
printf(" $ Cooking Style $ \n\n");
printf(" && Please select the cooking that you would like && \n\n");
printf(" [1] ASAM PEDAS - RM 2.50\n");
printf(" [2] SAMBAL - RM 3.00\n");
printf(" [3] ROASTED - RM 5.00\n");
printf(" [4] GRILLED - RM 6.00\n");

printf("Enter your choice here : ");
scanf("%d", &choice);
{
if (choice == 1)
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 2.50 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ", total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
brst();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 2)
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 3.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
//Allows user to choose whether to check-out or buy anything else.
scanf("%d", &again);
system("clear");
  
if (again == 1 )
brst();
else if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 3 )
{
printf("Enter quantity (pieces): ");
scanf("%d", &quantity);
total = 5.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ", total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
brst();
else if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\nSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 4 )
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 6.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
// Allows user to choose whether to check-out or buy anything else.
scanf("%d", &again);
system("clear");
  
if (again == 1 )
{
brst();
}
else
if (again == 2 )
{
menu();
}
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if (choice != 1 , 2 , 3 )
{
printf("\n\n\t\t Invalid Choice Entered\n\n");
ex();
}
}
}

void thight()
{
int choice;
int quantity;
int again;

printf(" Welcome to Chicken Chicky Place. \n ");
printf(" $ Cooking style $ \n\n");
printf(" && Please select the cooking style that you would like to purchase. &&\n\n");
printf(" [1] ASAM PEDAS - RM 2.50\n");
printf(" [2] SAMBAL - RM 3.00\n");
printf(" [3] ROASTED - RM 5.00\n");
printf(" [4] GRILLED - RM 6.00\n");
  
printf("Enter your choice here : ");
scanf("%d", &choice);
{
if (choice == 1)
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 2.50* quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ", total);
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
thight();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\nSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
}
else
if ( choice == 2)
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 3.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
if (again == 1 )
thight();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\nSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
}
else
if ( choice == 3 )
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 5.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No :");
scanf("%d", &again);
system("clear");
if (again == 1 )
thight();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
}
else
if ( choice == 4 )
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 6.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No :");
scanf("%d", &again);
system("clear");
if (again == 1 )
thight();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
}
else
if (choice != 1 , 2 , 3)
{
printf("\n\n Invalid Choice Entered\n\n");
thight();
}
}

}

void wings()
{
int choice;
int quantity;
int again;


printf(" Welcome to Chicken Chicky Place. \n ");
printf(" $ Cooking style $ \n\n");
printf(" && Please select the cooking style that you would like to purchase. &&\n\n");
printf(" [1] ASAM PEDAS - RM 2.50\n");
printf(" [2] SAMBAL - RM 3.00\n");
printf(" [3] ROASTED - RM 5.00\n");
printf(" [4] GRILLED - RM 6.00\n");

printf("Enter your choice here : ");
scanf("%d", &choice);
{
if (choice == 1)
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 2.50 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n ", total);
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
wings();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\nSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
}
else
if ( choice == 2)
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 3.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n ", total);
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
wings();
else
if (again == 2 )
menu();
else
if (again != 1 , 2 )
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
}
else
if ( choice == 3 )
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 5.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No :");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
wings();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\nSorry Invalid Decision Entered\n\n\n\n");
ex();
}
  
}
}
else
if ( choice == 4 )
{
printf("Enter quantity (pieces): ");
scanf("%d", &quantity);
total = 6.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No :");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
wings();
else
if (again == 2 )
menu();
else
if (again != 1 , 2 )
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
  
}
}
else
if (choice != 1 , 2 )
{
printf("\n\n Invalid Choice Entered\n\n");
wings();
}
}
}

void back()
{
int choice = 0;
int quantity = 0;
int again = 0;

printf("\n Welcome to Chicken Chicky Place. \n ");
printf(" $ Cooking Style $ \n\n");
printf(" && Please select the cooking that you would like && \n\n");
printf(" [1] ASAM PEDAS - RM 2.50\n");
printf(" [2] SAMBAL - RM 3.00\n");
printf(" [3] ROASTED - RM 5.00\n");
printf(" [4] GRILLED - RM 6.00\n");

printf("Enter your choice here : ");
scanf("%d", &choice);
{
if (choice == 1)
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 2.50 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ", total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
  
if (again == 1 )
back();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 2)
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 3.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
//Allows user to choose whether to check-out or buy anything else.
scanf("%d", &again);
system("clear");
  
if (again == 1 )
back();
else if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 3 )
{
printf("Enter quantity (KG): ");
scanf("%d", &quantity);
total = 5.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ", total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
back();
else if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\nSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 4 )
{
printf("Enter quantity (KG) : ");
scanf("%d", &quantity);
total = 6.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
// Allows user to choose whether to check-out or buy anything else.
scanf("%d", &again);
system("clear");
  
if (again == 1 )
{
back();
}
  
else
if (again == 2 )
{
menu();
}
  
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if (choice != 1 , 2 , 3 )
  
printf("\n\n\t\t Invalid Choice Entered\n\n");
ex();
}
}

void neck()
{
int choice = 0;
int quantity = 0;
int again = 0;
  
printf("\n Welcome to Chicken Chicky Place. \n ");
printf(" $ Cooking Style $ \n\n");
printf(" && Please select the cooking that you would like && \n\n");
printf(" [1] ASAM PEDAS - RM 2.50\n");
printf(" [2] SAMBAL - RM 3.00\n");
printf(" [3] ROASTED - RM 5.00\n");
printf(" [4] GRILLED - RM 6.00\n");

printf("Enter your choice here : ");
scanf("%d", &choice);
{
if (choice == 1)
{
printf("Enter quantity (KG) : ");
scanf("%d", &quantity);
total = 2.50 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ", total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
  
if (again == 1 )
neck();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 2)
{
printf("Enter quantity (KG) : ");
scanf("%d", &quantity);
total = 3.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
//Allows user to choose whether to check-out or buy anything else.
scanf("%d", &again);
system("clear");
  
  
if (again == 1 )
neck();
else if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 3 )
{
printf("Enter quantity (KG): ");
scanf("%d", &quantity);
total = 5.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ", total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
neck();
else if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\nSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 4 )
{
printf("Enter quantity (KG) : ");
scanf("%d", &quantity);
total = 6.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
// Allows user to choose whether to check-out or buy anything else.
scanf("%d", &again);
system("clear");
  
if (again == 1 )
{
neck();
}
else
if (again == 2 )
{
menu();
}
  
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if (choice != 1 , 2 , 3 )
{
printf("\n\n\t\t Invalid Choice Entered\n\n");
ex();
}
}
}

void ex() // Exit Screen
{
printf("\n");
printf(" Thank You Very Much \n ");
printf(" && Please come again. && \n\n");
}

In: Computer Science

Python: def factors(matrix, factor): The matrix is a 3D list of integers. factors are either one,...

Python:

def factors(matrix, factor):

The matrix is a 3D list of integers.

factors are either one, two, or three

If the factor is 'one' it will return a the first value from each list

if the factor is 'two' it will return the second value, and same for the third.

Example;

input = [ [ [1, 2, 3], [3, 2, 9], [9, 8, 6] ],

[ [0, 0, 4], [8, 9, 0], [5, 2, 1] ],

[ [0, 1, 1], [5, 5, 9], [3, 8, 4] ] ], 'one')

output = [ [1, 3, 9], [0, 8, 5], [0, 5, 3] ]

In: Computer Science