Questions
python programming • Appropriate and well constructed while and/or for loops (as necessary). • Appropriate if,...

python programming

• Appropriate and well constructed while and/or for loops (as necessary). • Appropriate if, if-else, if-elif-else statements (as necessary). • The use of the ord() and chr() functions (as necessary). • The following three functions (refer to stage 6 for description): o display_details() o get_menu_choice() o get_offset() • Output that strictly adheres to the assignment specifications. If you are not sure about these details, you should check with the ‘Sample Output – Part II’ provided at the end of this document. • Good programming practice: o Consistent commenting, layout and indentation. You are to provide comments to describe: your details, program description, all variable definitions, and significant sections of code. o Meaningful variable names. • Your solutions MAY make use of the following built-in functions and methods: o Any of the Python built-in functions… specifically, you may find you may need the following: int(), input(), print(), range(), ord(),and chr(). • Your solutions MAY ALSO make use of the following: o Concatenation (+) operator to create/build new strings. o Access the individual elements in a string with an index (one element only). i.e. string_name[index]. o Your own (user-defined) functions (in addition to the three functions listed above). Your solutions MUST NOT use: • break, or continue statements in your solution. Do not use the quit() or exit() functions or the break or return statements (or any other techniques) as a way to break out of loops. Doing so will result in a significant mark deduction.

Sample output

*** Menu ***

1. Encrypt string

2. Decrypt string

3. Brute force decryption

4. Quit

What would you like to do [1,2,3,4]? 1

Please enter string to encrypt: Elvis has left the building!

Please enter offset value (1 to 94): 3

Encrypted string: Hoylv#kdv#ohiw#wkh#exloglqj$

*** Menu ***

1. Encrypt string

2. Decrypt string

3. Brute force decryption

4. Quit What would you like to do [1,2,3,4]? 2

Please enter string to decrypt: Hoylv#kdv#ohiw#wkh#exloglqj$ Please enter offset value (1 to 94): 3

Decrypted string: Elvis has left the building!

*** Menu ***

1. Encrypt string

2. Decrypt string

3. Brute force decryption

4. Quit What would you like to do [1,2,3,4]? 3

Please enter string to decrypt: Hoylv#kdv#ohiw#wkh#exloglqj$

Offset: 1 = Decrypted string: Gnxku"jcu"nghv"vjg"dwknfkpi# Offset: 2 = Decrypted string: Fmwjt!ibt!mfgu!uif!cvjmejoh" Offset: 3 = Decrypted string: Elvis has left the building! Offset: 4 = Decrypted string: Dkuhr~g`r~kdes~sgd~athkchmf Offset: 5 = Decrypted string: Cjtgq}f_q}jcdr}rfc}`sgjbgle~ Offset: 6 = Decrypted string: Bisfp|e^p|ibcq|qeb|_rfiafkd} Offset: 7 = Decrypted string: Ahreo{d]o{habp{pda{^qeh`ejc| Offset: 8 = Decrypted string: @gqdnzc\nzg`aozoc`z]pdg_dib{ Offset: 9 = Decrypted string: ?fpcmyb[myf_`nynb_y\ocf^chaz Offset: 10 = Decrypted string: >eoblxaZlxe^_mxma^x[nbe]bg`y Offset: 11 = Decrypted string: =dnakw`Ykwd]^lwl`]wZmad\af_x Offset: 12 = Decrypted string: P\IBCQ\QEB\?RFIAFKD] Offset: 39 = Decrypted string: !HREO[D=O[HABP[PDA[>QEH@EJC\ Offset: 40 = Decrypted string: GQDNZCCHAZ Offset: 42 = Decrypted string: }EOBLXA:LXE>?MXMA>X;NBE=BG@Y Offset: 43 = Decrypted string: |DNAKW@9KWD=>LWL@=W:MADW Offset: 45 = Decrypted string: zBL?IU>7IUB;;U8K?B:?D=V Offset: 46 = Decrypted string: yAK>HT=6HTA:;ITI=:T7J>A9>CH;EQ:3EQ>78FQF:7Q4G;>6;@9R Offset: 50 = Decrypted string: u=G:DP92DP=67EPE96P3F:=5:?8Q Offset: 51 = Decrypted string: t7P Offset: 52 = Decrypted string: s;E8BN70BN;45CNC74N1D8;38=6O Offset: 53 = Decrypted string: r:D7AM6/AM:34BMB63M0C7:27<5N Offset: 54 = Decrypted string: q9C6@L5.@L923ALA52L/B6916;4M Offset: 55 = Decrypted string: p8B5?K4-?K812@[email protected]:3L Offset: 56 = Decrypted string: o7A4>J3,>J701?J?30J-@47/492K Offset: 57 = Decrypted string: n6@3=I2+=I6/0>I>2/I,?36.381J Offset: 58 = Decrypted string: m5?2

25-270I Offset: 59 = Decrypted string: l4>1;G0);G4-.' 2>+$%3>3'$>!4(+#(-&? Offset: 69 = Decrypted string: b*4'1=&~1=*#$2=2= 3'*"',%> Offset: 70 = Decrypted string: a)3&0<%}0<)"#1<1%"<~2&)!&+$= Offset: 71 = Decrypted string: `(2%/;$|/;(!"0;0$!;}1%( %*#< Offset: 72 = Decrypted string: _'1$.:#{.:' !/:/# :|0$'~$)"; Offset: 73 = Decrypted string: ^&0#-9"z-9&~ .9."~9{/#&}#(!: Offset: 74 = Decrypted string: ]%/",8!y,8%}~-8-!}8z."%|"' 9 Offset: 75 = Decrypted string: \$.!+7 x+7$|},7, |7y-!${!&~8 Offset: 76 = Decrypted string: [#- *6~w*6#{|+6+~{6x, #z %}7 Offset: 77 = Decrypted string: Z",~)5}v)5"z{*5*}z5w+~"y~$|6 Offset: 78 = Decrypted string: Y!+}(4|u(4!yz)4)|y4v*}!x}#{5 Offset: 79 = Decrypted string: X *|'3{t'3 xy(3({x3u)| w|"z4 Offset: 80 = Decrypted string: W~){&2zs&2~wx'2'zw2t({~v{!y3 Offset: 81 = Decrypted string: V}(z%1yr%1}vw&1&yv1s'z}uz x2 Offset: 82 = Decrypted string: U|'y$0xq$0|uv%0%xu0r&y|ty~w1 Offset: 83 = Decrypted string: T{&x#/wp#/{tu$/$wt/q%x{sx}v0 Offset: 84 = Decrypted string: Sz%w".vo".zst#.#vs.p$wzrw|u/ Offset: 85 = Decrypted string: Ry$v!-un!-yrs"-"ur-o#vyqv{t. Offset: 86 = Decrypted string: Qx#u ,tm ,xqr!,!tq,n"uxpuzs- Offset: 87 = Decrypted string: Pw"t~+sl~+wpq + sp+m!twotyr, Offset: 88 = Decrypted string: Ov!s}*rk}*vop~*~ro*l svnsxq+ Offset: 89 = Decrypted string: Nu r|)qj|)uno})}qn)k~rumrwp* Offset: 90 = Decrypted string: Mt~q{(pi{(tmn|(|pm(j}qtlqvo) Offset: 91 = Decrypted string: Ls}pz'ohz'slm{'{ol'i|pskpun( Offset: 92 = Decrypted string: Kr|oy&ngy&rklz&znk&h{orjotm' Offset: 93 = Decrypted string: Jq{nx%mfx%qjky%ymj%gznqinsl& Offset: 94 = Decrypted string: Ipzmw$lew$pijx$xli$fymphmrk%

*** Menu ***

1. Encrypt string

2. Decrypt string

3. Brute force decryption

4. Quit What would you like to do [1,2,3,4]? 4 Goodbye.

Note: Your program must work with the printable ASCII character set. That is, all the characters from ASCII 32 (Space) to ASCII 126 (~). When the offset points to a character beyond 126 it should wrap around to the beginning of the set.

In: Computer Science

Homework Assignment 4 Instructions: Class name must be: HW4_yourName For example: Michael will name the class...

Homework Assignment 4 Instructions: Class name must be: HW4_yourName For example: Michael will name the class of homework assignment 4 as HW4_Michael Grading Rubric: Code running and as per the required conditions and giving expected output = 10 points File named as per instructions = 1 point Comments in code = 4 points Problem: Average calculation for a list Write a program that reads a text file named test_scores.txt to read the name of the student and his/her scores for 3 tests. The program should display class average for first test (average of scores of test 1) and average (average of 3 tests) for each student. Expected Output: ['John', '25', '26', '27'] ['Michael', '24', '28', '29'] ['Adelle', '23', '24', '20'] [['John', '25', '26', '27'], ['Michael', '24', '28', '29'], ['Adelle', '23', '24', '20']] Class average for test 1 is: 24.0 Average for student John is 26.00 Average for student Michael is 27.00 Average for student Adelle is 22.33

In: Computer Science

Implement C++ program for each of the following. Let D = [-48, -14, -8, 0, 1,...

Implement C++ program for each of the following.
Let D = [-48, -14, -8, 0, 1, 3, 16, 23, 26, 32, 36] Each answer is either True or False. If False, give example
of number(s) that make it False. i.e. The Counterexample. ∀x∈D, if x is odd then x > 0
Let D = [-48, -14, -8, 0, 1, 3, 16, 23, 26, 32, 36] Each answer is either True or False. If False, give example
of number(s) that make it False. i.e. The Counterexample. ∀x∈D, if x is less than 0 then x is even.
Let D = [-48, -14, -8, 0, 1, 3, 16, 23, 26, 32, 36] Each answer is either True or False. If False, give example
of number(s) that make it False. i.e. The Counterexample. ∀x∈D, if x is even then x <= 0;
Let D = [-48, -14, -8, 0, 1, 3, 16, 23, 26, 32, 36] Each answer is either True or False. If False, give example
of number(s) that make it False. i.e. The Counterexample. ∀x∈D, if the ones digit of x is 2, then the tens
digit is 3 or 4.
Let D = [-48, -14, -8, 0, 1, 3, 16, 23, 26, 32, 36] Each answer is either True or False. If False, give example
of number(s) that make it False. i.e. The Counterexample. ∀x∈D, if the ones digit of x is 6, then the tens
digit is 1 or 2.

In: Computer Science

Recursion. Question 1 1.1 What are the 2 main components of a recursive function? 1.2 What...

Recursion.

Question 1

1.1 What are the 2 main components of a recursive function?

1.2 What is more efficient: an explicit loop structure or a recursive function? Explain your answer.

1.3 In what scenarios should a recursive solution be preferred to an iterative solution?

In: Computer Science

Write a program that has a function (named getNumStats()) that will return a string that has...

Write a program that has a function (named getNumStats()) that will return a string that has stats on the number entered.

The prototype is:

string getNumStats(double);

The stats are:

            Is the number an integer or a double?

            The polarity (is it positive or negative; 0 counts as positive)

            The parity (is it odd or even)

            Is it a prime number? (for this program, 1 is considered a prime number)

For example, if the following lines of code are executed

double dNum = 14.06;

string test = getNumStats(dNum)

cout << test << endl;

The output that appears on the screen will be:

14.06 is a double

It is positive

It does not have parity

It is not a prime number

Another run is:

double dNum = -27.371;

string test = getNumStats(dNum)

cout << test << endl;

The output that appears on the screen will be:

-23.371 is a double

It is negative

It does not have parity

It is not a prime number

Note: your first line of output may or may not show trailing zeros. You may add that feature to always show zeros (even if the number is an integer)

In: Computer Science

How can I analyze "Enron Dataset" using ONLY "Naive Bayes model" or "SVM(Support Vector Machine) model"...

How can I analyze "Enron Dataset" using ONLY "Naive Bayes model" or "SVM(Support Vector Machine) model" or "Decision Trees model" or  "Random Forest model" or "K Nearest Neighbors model". And for what purpose the result can be used? Please give me some rough ideas and methods. No need to right down the Python codes.

In: Computer Science

Explain the similarities and differences between Drop (a table), Truncate (the data), and Delete (the data).

Explain the similarities and differences between Drop (a table), Truncate (the data), and Delete (the data).

In: Computer Science

I created a shoppingcart program but I'm getting a few compilation failed errors: 1) Tests that...

I created a shoppingcart program but I'm getting a few compilation failed errors:

1) Tests that ItemToPurchase("Bottled Water", "Deer Park, 12 oz.", 1, 10) correctly initializes item compilation failed

2) Tests default constructor and accessors for ShoppingCart Compilation failed

3)Tests ShoppingCart("John Doe", "February 1, 2016") correctly initializes cart Compilation failed

4) Tests that getNumItemsInCart() returns 6 (ShoppingCart) compilation failed

5) Test that getCostOfCart() returns 9 (ShoppingCart) compilation failed

Complete program:

itemtopurchase.java

public class ItemToPurchase {
// instance variables
private String itemName;
private String itemDescription;
private int itemPrice;
private int itemQuantity;
// default constructor
public ItemToPurchase() {
this.itemName = "none";
this.itemDescription = "none";
this.itemPrice = 0;
this.itemQuantity = 0;
}
public ItemToPurchase(String itemName, int itemPrice, int itemQuantity,String itemDescription) {
this.itemName = itemName;
this.itemDescription = itemDescription;
this.itemPrice = itemPrice;
this.itemQuantity = itemQuantity;
}
// method to set name of the item
public void setName(String name) {
itemName = name;
}
// method to set price of the item
public void setPrice(int price) {
itemPrice = price;
}
// method to set quantity of the item
public void setQuantity(int quantity) {
itemQuantity = quantity;
}
public void setDescription(String description) {
itemDescription = description;
}
// method to get name of the item
public String getName() {
return itemName;
}
// method to get price of the item
public int getPrice() {
return itemPrice;
}
// method to get quantity of the item
public int getQuantity() {
return itemQuantity;
}
public String getDescription() {
return itemDescription;
}
public void printItemPurchase() {
System.out.println(itemName + " " + itemQuantity + " @ $" + itemPrice + " = $" + (itemPrice * itemQuantity));
}
public void printItemDescription() {

System.out.println(itemName+": "+itemDescription);
}
}

shoppingcart.java

import java.util.ArrayList;

public class ShoppingCart {

//instance variables
private String customerName;
private String currentDate;
private ArrayList<ItemToPurchase> cartItems = new ArrayList<ItemToPurchase>();

//Default constructor
public ShoppingCart() {
customerName = "";
currentDate = "";
}

//parameterized constructor
public ShoppingCart(String customerName, String currentDate) {
this.customerName = customerName;
this.currentDate = currentDate;
}

//getter methods
public String getCustomerName() {
return customerName;
}

public String getCurrentDate() {
return currentDate;
}

//add items
public void addItem(ItemToPurchase item) {
cartItems.add(item);
}

//remove item
public void removeItem(String name) {
for (ItemToPurchase i : cartItems) {
if (i.getName().equalsIgnoreCase(name)) {
cartItems.remove(i);
return;
}
}

System.out.println("Item not found in cart");
}

//modify the item
public void modifyItem(ItemToPurchase item) {
for (int i = 0; i < cartItems.size(); i++) {
if (cartItems.get(i).getName().equalsIgnoreCase(item.getName())) {
if (!item.getDescription().equals("none") && !(item.getPrice() == 0) && !(item.getQuantity() == 0)) {
cartItems.add(i, item);
return;
}
}
}

System.out.println("Item not found in cart. Nothing modified");

}

//get total number of items in the cart
public int getNumItemsIncart() {
int sum = 0;
for (ItemToPurchase i : cartItems) {
sum += i.getQuantity();
}
return sum;
}

//get total cost of items in the cart
public int getCostOfcart() {
int sum = 0;
for (ItemToPurchase i : cartItems) {
sum += i.getPrice();
}
return sum;
}

//printing total of each items
public void printTotal() {
System.out.println(customerName + "'s Shopping Cart - " + currentDate);
if (cartItems.isEmpty()) {
System.out.println("Shopping Cart is Empty");
return;
}

System.out.println("Number of Items: " + cartItems.size());
System.out.println();
for (ItemToPurchase i : cartItems) {
i.printItemPurchase();
}
System.out.println();
System.out.println("Total: $" + getCostOfcart());
}

//printing description of all items
public void printDescription() {
System.out.println(customerName + "'s Shopping Cart - " + currentDate);
System.out.println();
if (cartItems.isEmpty()) {
System.out.println("Shopping Cart is Empty");
return;
}
System.out.println("Item Descriptions: ");
for (ItemToPurchase i : cartItems) {
i.printItemDescription();
}
}
}

shoppingcartmanager.java

import java.util.Scanner;

public class ShoppingCartManager {

// method to add an item in the cart
public static void addCartItem(Scanner scan, ShoppingCart cart) {
String itemName, itemDescription;
int itemPrice, itemQuantity;
System.out.println("ADD ITEM TO CART");
System.out.print("Enter the item name : ");
itemName = scan.nextLine();
System.out.print("Enter the item description : ");
itemDescription = scan.nextLine();
System.out.print("Enter the item price : ");
itemPrice = scan.nextInt();
System.out.print("Enter the item quantity : ");
itemQuantity = scan.nextInt();
scan.nextLine();

cart.addItem(new ItemToPurchase(itemName, itemPrice, itemQuantity, itemDescription));

}

// method to remove an item from the cart
public static void removeCartItem(Scanner scan, ShoppingCart cart) {
String itemName;
System.out.println("REMOVE ITEM FROM CART");
System.out.print("Enter the name of item to remove : ");
itemName = scan.nextLine();

cart.removeItem(itemName);
}

// method to change quantity of the cart
public static void changeItemQuantity(Scanner scan, ShoppingCart cart) {
String itemName;
int itemQuantity;
System.out.println("CHANGE ITEM QUANTITY");
System.out.print("Enter the item name : ");
itemName = scan.nextLine();
System.out.print("Enter the new quantity : ");
itemQuantity = scan.nextInt();
scan.nextLine();
cart.modifyItem(new ItemToPurchase(itemName, 0, itemQuantity, "none"));
}

// method to display menu choices and perform the operations on the cart until
// the user quits
public static void printMenu(ShoppingCart cart) {
String choice;
Scanner scan = new Scanner(System.in);
do {
System.out.println("\nMENU");
System.out.println("a - Add item to cart");
System.out.println("d - Remove item from cart");
System.out.println("c - Change item quantity");
System.out.println("i - Output items' description");
System.out.println("o - Output shopping cart");
System.out.println("q - Quit");
System.out.print("\nChoose an option : ");
choice = scan.nextLine();

if (choice.equalsIgnoreCase("a")) {
addCartItem(scan, cart);
} else if (choice.equalsIgnoreCase("d")) {
removeCartItem(scan, cart);
} else if (choice.equalsIgnoreCase("c")) {
changeItemQuantity(scan, cart);
} else if (choice.equalsIgnoreCase("o")) {
System.out.println("OUTPUT SHOPPING CART");
cart.printTotal();
} else if (choice.equalsIgnoreCase("i")) {
System.out.println("OUTPUT ITEMS' DESCRIPTION");
cart.printDescription();
} else if (!choice.equalsIgnoreCase("q"))
System.out.println("Invalid choice");

} while (!choice.equalsIgnoreCase("q"));

}

public static void main(String args[]) {
Scanner sc = new Scanner(System.in);

// taking user input
System.out.println("Enter Customer's Name:");
String name = sc.nextLine();
System.out.println("Enter Today's Date:");
String date = sc.nextLine();

// printing user input
System.out.println();
System.out.println("Customer Name: " + name);
System.out.println("Today's Date: " + date);

ShoppingCart cart = new ShoppingCart(name, date);// created shopping cart object
printMenu(cart);
}
}

In: Computer Science

How could I implement the contain and min method for a tree in this code. import...

How could I implement the contain and min method for a tree in this code.


import java.util.List;
import edu.princeton.cs.algs4.*;


class ProgrammingAssignment1 {

    //////////////////// EXERCICE 1: TWO THREE TREES

    static public <Key extends Comparable<Key>>
    int size (NakedTree<Key> tree) {
      if (tree == null)
        return 0;
      int val = tree.getNKeys ();
      for (int i = 0; i <= tree.getNKeys (); ++i)
        val += size (tree.getChild (i));
      return val;
    }

    //////// EXERCICE 1.1: contains AND min

    static public <Key extends Comparable<Key>>
    boolean contains (NakedTree<Key> tree, Key key) {

       
    }

In: Computer Science

Hello, I have a problem with understanding this line. forEach(value.split("<br>"), line, line.trim()).slice(-3).join("\n") This line is for...

Hello, I have a problem with understanding this line.

forEach(value.split("<br>"), line, line.trim()).slice(-3).join("\n")

This line is for the open refine program. Could you tell me what this line is trying to do? I have no idea what this is for...

For your information, this line appeared when professor was talking about 'Fetching and Parsing HTML'..

Thank you for answering my question and have a good day!

p.s. My professor told us to insert that line in the expression box and try to figure out what this expression means... As I'm not majoring in CS, it's too difficult for me to understand..;(

In: Computer Science

Discuss the open-source tools in general. What are the advantages versus disadvantages? What is the life-long...

Discuss the open-source tools in general. What are the advantages versus disadvantages? What is the life-long learning lesson you think you are able to acquire with this type of assignment? Discuss ethical and global issues.

In: Computer Science

1) Consider any recent acquisition by Facebook. Why do you think Facebook purchased the company? Suggest...

1) Consider any recent acquisition by Facebook. Why do you think Facebook purchased the company? Suggest ways in which the app has been monetized
2) With the emergence and now certaintly of online commerce, are store fronts still relevant in retail? If so, what role(s) do they play?

In: Computer Science

#include <stdio.h> int main(void) { int input = -1; double average = 0.0;    /* Use...

#include <stdio.h>

int main(void) {
int input = -1;
double average = 0.0;
  
/* Use this for your input */
scanf("%d", &input);
  
/* This is the only output you need */
printf("%.1lf", average);
return 0;
}

Please write a C coding program (make it simple coding)  that find the average of sequence integer. when user enter integers, once at a time. Also, If the user enters 0 (zero), the code will calculates the average and then prints it, and then exits.

In: Computer Science

________ means that IT capacity can be easily scaled up or down as needed, which essentially...

  1. ________ means that IT capacity can be easily scaled up or down as needed, which essentially requires cloud computing.
  1. agility
  2. flexibility
  3. responsiveness
  4. IT consumerization
  1. ________ is the migration of privately-owned mobile devices into enterprise IT environments.
  1. agility
  2. flexibility
  3. responsiveness
  4. IT consumerization
  1. Influential industry leaders cite ____________ as their largest business challenge in sustaining a competitive edge.
  1. keeping up with technology
  1. employee performance
  2. economic climate
  3. new competition
  1. A website or app that is scaled to be viewed from a computer, tablet, or smartphone is said to be_________.
  1. responsive
  2. flexible
  3. agile
  4. competitive
  1. IT agility, flexibility, and mobility are tightly interrelated and primarily dependent on:
  1. An organization’s IT infrastructure and architecture
  2. The IT division’s strategic hiring and training practices
  3. IT’s integration with production and accounting units
  4. Strategic alignment between IT budget and company mission statement
  1. Matt is using his own tablet for work purposes, which is an example of a trend called _____________.
  1. Mixed use IT
  2. Employer IT cost shifting
  3. IT consumerization
  4. BYOM
  1. Using a combination of mobile and database technology, Pizza House keeps records of the pizza preferences of all its customers. When Sam orders from Pizza House, he only says “send me the usual” when he calls in his order; and hangs up.   Accessing the database, the Pizza House worker knows his address, his usual order, and what credit card to bill. The streamlined ordering and fulfillment efficiency give the Pizza House __________.
  1. A strategic plan
  2. A strategic model
  3. A competitive advantage
  4. A sustainably business edge
  1. iTunes was a significant breakthrough that forever changed the music industry and the first representation of Apple's ________.
  1. IT consumerization
  2. Sustainable competitive advantage
  3. Incompatibility with Windows
  4. future outside its traditional computing product line
  1. How many times a day does the average American check their smartphone?
  1. 24
  2. 59
  3. 46
  4. 99
  1. IT job growth is estimated at ________ from 2014 to 2024, according to the U.S. Department of Labor.
  1. 12%
  2. 5%
  3. 33%
  4. Over 50%
  1. _____________ evaluate the newest and most innovative technologies and determine how they can be applied for competitive advantage. They develop technical standards, deploy technology, and supervise workers who deal with the daily IT issues of the firm.
  1. Project Managers
  2. Chief Technology Officers
  3. CEOs
  4. CFOs
  1. _____________ develop requirements, budgets, and schedules for their firm’s information technology projects. They coordinate such projects from development through implementation, working with their organization’s IT workers, as well as clients, vendors, and consultants.
  1. Project Managers
  2. Chief Technology Officers
  3. CEOs
  4. CFOs

In: Computer Science

I need to create a servlet that takes in an input that will do the following...

I need to create a servlet that takes in an input that will do the following calculations.

  1. If the input number is a prime, just output a message showing that it is a prime;
  2. If the input number is not a prime and it is an odd integer, write it as a product of two smaller odd integers;
  3. If the input number is not a prime and it is an even integer, first extract the largest power of 2, then for the remaining odd number, try to factorize it if you can. For your output, you give the power of 2 as one number and one more factor if this factor is a prime, or two more factors if you can still factorize the odd number after extracting the power of 2.

In: Computer Science