Questions
Generate all permutations of {3, 8, 2} by the Johnson-Trotter algorithm. Show the steps.

Generate all permutations of {3, 8, 2} by the Johnson-Trotter algorithm. Show the steps.

In: Computer Science

Problem 1 The United States Federal Income tax for taxes due July 15, 2020 is available...

Problem 1
        The United States Federal Income tax for taxes due July 15, 2020
    is available at this link: https://www.bankrate.com/finance/taxes/tax-brackets.aspx
        The four tax filing categories are: 0 - single filer, 2 - head of household, 
        3 - married filing jointly or qualifying widow, and 4 - married filing
        seperately. 
        
        Write a Java program that prompts the user to enter the name, filing status, and
        annual income. The program returns the federal income tax due. (10 Points)
        
        A sample run should look like:
        Enter your name: Jane Doe
        Enter your 2019 federal income: 48,000
        Enter your filing status: single
        
        Jane Doe, the federal income tax for an annual salary of
        48,000 for a single filer is $4,800.
        
        
        Draw a UML diagram for the class. You may use Astah tool. (5 points).
        
        
        Submit both the java code and UML diagram.
*       

In: Computer Science

This is a beginner C++ class Your program will be creating 10 library books. Each library...

This is a beginner C++ class

Your program will be creating 10 library books. Each library book will have a title, author and publishing year. Each library book will be stored as a structure and your program will have an array of library books (an array of structures).

After creating the struct, the next task is to create a new separate array for book genres.

You will create this corresponding array of book genres: Mystery, Romance, Fantasy, Technology, Children, etc. If the first element of the structure is storing information about a book titled : "More about Paddington", then the corresponding first element of array book genre would indicate 'Children'.

You should only use structure and array. You are not allowed to use vectors.

The user of your program should be able to select what they want to do from a menu of the following things and your program needs to do what the menu selection indicates:

* Print the entire list of library books (including the title, author, publishing year and book genre)

* Display a count of how many books exist per genre

* Find and display all books where the publishing year is greater than the year user put in

* Print the titles of the books where the Genre may be indicated by a 'C' for Children, & 'M' for Mystery

In: Computer Science

Java Counter Program I can't get my program to add the number of times a number...

Java Counter Program

I can't get my program to add the number of times a number was landed on for my if statements for No12 through No2.

My Code:

import java.util.Scanner;
import java.util.Random;
   import java.lang.*;
  
   public class Dice
   {
      
       public static void main(String[] args)
       {
           Scanner in = new Scanner(System.in);
           int Continue = 1;
           //randomnum = new Random();
          
           do
           {
           RollDice();
          
           System.out.print("Would you like to go again? (Yes = 1, No =2");
           Continue = in.nextInt();
           }while(Continue == 1);  
       }

   public static void RollDice ()
   {
       Scanner in = new Scanner(System.in);
       //int die1;
       //int die2;
       int dieTotal;
       int times;
       int rollCount =1;
       int i,temp=0;
       int rollCounto = 1;
      
           int No12=0;
           int No11=0;
           int No10=0;
           int No9=0;
           int No8=0;
           int No7=0;
           int No6=0;
           int No5=0;
           int No4=0;
           int No3=0;
           int No2=0;
           Random diceRoller = new Random();
           System.out.print("Enter amount of rolls desired");  
       for(i=0; i<rollCounto;i++)
       {
           rollCounto = in.nextInt();
           rollCount = rollCounto;
          
           do
           {
               int die1 = diceRoller.nextInt(6) +1;
               int die2 = diceRoller.nextInt(6) +1;
               dieTotal = (die1 + die2);
               if(dieTotal == 12)
               {
                   No12= No12++;  
               }
               if(dieTotal == 11)
               {
                   No11= No11++;  
               }
               if(dieTotal == 10)
               {
                   No10= No10++;  
               }
               if(dieTotal == 9)
               {
                   No9= No9++;  
               }
               if(dieTotal == 8)
               {
                   No8= No8++;  
               }
               if(dieTotal == 7)
               {
                   No7= No7++;  
               }
               if(dieTotal == 6)
               {
                   No6= No6++;  
               }
               if(dieTotal == 5)
               {
                   No5= No5++;  
               }
               if(dieTotal == 4)
               {
                   No4= No4++;  
               }
               if(dieTotal == 3)
               {
                   No3= No3++;  
               }
               if(dieTotal == 2)
               {
                   No2= No2++;  
               }
               rollCount = (rollCount - 1);
           }while(rollCount >0);
           System.out.println("\n2 | " + No2 + "/36" + "\n3 | " + No3 + "/36" + "\n4 | " + No4 + "/36" + "\n5 | " + No5 + "/36" + "\n6 | " + No6 + "/36" +
           "\n7 | " + No7 + "/36" + "\n8 | " + No8 + "/36" + "\n9 | " + No9 + "/36" + "\n10 | " + No10 + "/36" + "\n11 | " + No11 + "/36" + "\n12 | " + No12 + "/36");
       break;
       }
      
      
   }
   }

In: Computer Science

What is the fundamental characteristic of software that is designed using a repository architecture? Give examples...

What is the fundamental characteristic of software that is designed using a repository architecture? Give examples with explanation please.

In: Computer Science

Determine whether or not you believe certifications in systems forensics are necessary and explain why you...

Determine whether or not you believe certifications in systems forensics are necessary and explain why you believe this to be the case. Compare and contrast certifications and on-the-job training and identify which you believe is more useful for a system forensics professional. Provide a rationale with your response.

In: Computer Science

What is the most important advantage and at least two disadvantages of a client-server architecture?

What is the most important advantage and at least two disadvantages of a client-server architecture?

In: Computer Science

Draw a (single) tree T, such that • Each internal node of T stores a single...

Draw a (single) tree T, such that

• Each internal node of T stores a single character;

• A preorder traversal of T yields: E K D M J G I A C F H B L;

• A postorder traversal of T yields: D J I G A M K F L B H C E.

Part2

Let T be an ordered tree with more than one node. Is it possible that the preorder traversal of T visits the nodes in the same order as the post order traversal of T ? If so, give an example. If not, then explain why this cannot occur.

In: Computer Science

Why do we need a TCP/IP-OSI hybrid (5) model, when we already have the TCP/IP model?

Why do we need a TCP/IP-OSI hybrid (5) model, when we already have the TCP/IP model?

In: Computer Science

write an algorithm and python program using the following information. also can y How much should...

write an algorithm and python program using the following information. also can y

How much should I study outside of class?

           

            Issue:

Your fellow students need help. This is their first year in college and they need to determine how many hours they need to study to get good grades.

Study Hours Per Week Per Class                    Grade

15                                                           A

12                                                           B

9                                                             C

6                                                             D

0                                                             F

Project Specifications:

  1. The user enters their full name and the number of credits they are taking.
  2. The user will then enter the grade they want assuming the same grade for all classes.
  3. The program displays for each student: student’s name, number of credits, total number of weekly study hours, and grade they should expect to receive. In the following format –

Name: FirstName LastName

Credits: 12

Study Hours: 60

Grade: A

  1. At the end of the program, the program displays the total number of students who used the program, the average credits taken, and the average study hours. In the following format –

Total Students: 3

Average Credits: 9

Average Study Hours: 20

ou please run the program?

In: Computer Science

Background: You can create a simple form of encryption using the xor Boolean operator. For example,...

Background:
You can create a simple form of encryption using the xor Boolean operator. For example, if you want to encrypt the letter 'A':

  1. Choose another letter as a "key", say 'X'
  2. Encrypt 'A' with the xor function: encrypted = 'A' xor 'X'
  3. Now you can decrypt by xor'ing your encrypted value with 'X' again: decrypted = encrypted xor 'X'

Your task:
Write a C++ program that meets the following requirements:

  1. Asks the user for the name of an input file and a "key" character
  2. Encrypt each character in the file using the provided key and the xor function. (Note: The program should handle all standard alphanumeric characters.)
  3. Your program should save the results of the encryption into a new file with the same base name, but with a ".xor" file extension.
  4. The program should also provide an option to decrypt a given file.
  5. Include appropriate error checking.

Submit:

  • Fully documented source code

Documentation should include:

  • Pseudocode
  • Top comment block (The name of the program, The name of the programmer, The date of the program, and A brief description of the purpose of the program)
  • Function comments (Description, pre and post conditions)
  • Internal comments for all functions

In: Computer Science

JAVA CODE Define a method called changeGroupPrice that could be added to the definition of the...

JAVA CODE

Define a method called changeGroupPrice that could be added to the definition of the class Purchase. This method has one parameter that is of type double, and is named salePercent. This number represents the percent reduction in the groupPrice amount.   The method uses this number to change the groupPrice. The code of the method should check to make sure the range of salePercent is between 0 and 50%. If it is, the groupPrice should be adjusted accordingly. If the salePercent is out of range of the accepted values an error message should be printed and the program terminated.

public class PurchaseDemo

{ public static void main(String[] args)

{

Purchase oneSale = new Purchase();

oneSale.readInput();

oneSale.writeOutput();

System.out.println("Cost each $" + oneSale.getUnitCost());

System.out.println("Total cost $" + oneSale.getTotalCost());

}

}

import java.util.Scanner;
/**   
Class for the purchase of one kind of item, such as 3 oranges.
Prices are set supermarket style, such as 5 for $1.25.
*/
public class Purchase   
{
private String name;
private int groupCount; //Part of a price, like the 2 in //2 for $1.99.
private double groupPrice; //Part of a price, like the $1.99
// in 2 for $1.99.
private int numberBought; //Number of items bought.
public void setName(String newName)
{
name = newName;
}
/**   
Sets price to count pieces for $costForCount.   
For example, 2 for $1.99.   
*/
public void setPrice(int count, double costForCount)
{
if ((count <= 0) || (costForCount <= 0))
{
System.out.println("Error: Bad parameter in " +
"setPrice.");
System.exit(0);
}
else
{
groupCount = count;
groupPrice = costForCount;
}
}
public void setNumberBought(int number)
{
if (number <= 0)
{
System.out.println("Error: Bad parameter in " +
"setNumberBought.");
System.exit(0);
}
else
numberBought = number;
}
/**
Reads from keyboard the price and number of a purchase.
*/   
public void readInput()
{
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter name of item you are purchasing:");
name = keyboard.nextLine();
System.out.println("Enter price of item as two numbers.");
System.out.println("For example, 3 for $2.99 is entered as");
System.out.println("3 2.99");
System.out.println("Enter price of item as two numbers, " +
"now:");
groupCount = keyboard.nextInt();
groupPrice = keyboard.nextDouble();
while ((groupCount <= 0) || (groupPrice <= 0))
{ //Try again:
System.out.println("Both numbers must " +
"be positive. Try again.");
System.out.println("Enter price of " +
"item as two numbers.");
System.out.println("For example, 3 for " +
"$2.99 is entered as");
System.out.println("3 2.99");
System.out.println(
"Enter price of item as two numbers, now:");
groupCount = keyboard.nextInt();
groupPrice = keyboard.nextDouble();
}
System.out.println("Enter number of items purchased:");
numberBought = keyboard.nextInt();
while (numberBought <= 0)
{ //Try again:
System.out.println("Number must be positive. " +
"Try again.");
System.out.println("Enter number of items purchased:");
numberBought = keyboard.nextInt();
}
}
/**   
Displays price and number being purchased.
*/
public void writeOutput()   
{
System.out.println(numberBought + " " + name);
System.out.println("at " + groupCount +
" for $" + groupPrice);
}
public String getName()
{
return name;
}
public double getTotalCost()
{
return (groupPrice / groupCount) * numberBought;
}
public double getUnitCost()
{
return groupPrice / groupCount;
}
public int getNumberBought()
{
return numberBought;
}
}

In: Computer Science

For this assignment I need to use information from a previous assignment which I will paste...

For this assignment I need to use information from a previous assignment which I will paste here:

#ifndef TODO
#define TODO
#include <string>

using std::string;

const int MAXLIST = 10;

struct myToDo
{
    string description;
    string dueDate;
    int priority;
};

bool addToList(const MyToDo &td);
bool addToList(string description, string date, int priority);
bool getNextItem(MyToDo &td);
bool getNextItem(string &description, string &date, int &priority);
bool getByPriority(MyToDo list[], int priority int &count);
void printToDo();

#endif



#include <iostream>
#include "ToDo.h"

using namespace std;

myToDo ToDoList[MAXLIST];
int head = 0, tail = -1;

bool addToList(const myToDo &td)
{
    if(head < MAXLIST)
    {
        if(tail == -1)
            tail++;
        ToDoList[head] = td;
        head++;
        return true;
    }
    return false;
}
bool addTolist(string description, string date, int priority)
{
    MyToDo td;
    td.description = description;
    td.dueDate = date;
    td.priority = priority;
    return addToList(td);
}
bool getNextItem(MyToDo &td)
{
    if(tail >= 0)
    {
        if(tail >= MAXLIST)
            tail = 0;
        td = ToDoList[tail];
        tail++;
        return true;
    }
    return false;
}
bool getNextItem(string &description, string &date, int&priority)
{
    myToDo tmp;
    bool status = getNextItem(tmp);
    if(status == true)
    {
        description = tmp.description;
        date = tmp.dueDate;
        priority = tmp.priority;
    }

    return status;
}
bool getByPriority(MyToDo list[], int priority, int &count)
{
    if(tail < 0)
            return fals;
        count = 0;
        for(int i = 0; i < head; i++)
        {
            if(ToDoList[i].priority == priority)
            {
                list[count] = ToDoList[i];
                count++;
            }
    }
    if(count > 0)
            return true;
        return false;
}
void printToDo())
{
    for(int i = 0; i < head; i++)
    {
        cout << "Description" << ToDoList[i].description << endl;
        cout << "Due Date" << ToDoList[i].dueDate << endl;
        cout << "Priority" << ToDoList[i].priority << endl;
    }

With this info I am asked:

Creating A Classes

This assignment is geared to check your understanding of Object Oriented Programming and class creationg. The class type is called a complex type because it is a type that you create from the primitive types of the language. Even though you create it it is still a full fledged type.

This activity is designed to support the following Learning Objective:

  • Differentiate between object-oriented, structured, and functional programming methodologies.

Instructions

In Assignment 19 you created a simple ToDo list that would hold structs that contained information about each item that would be in the list.. For this assignment I want you to take lab 19 an create a class out of it.

Your class should be called ToDoList. The definition for the ToDoList should be in the header file. The variables that make up the data section should be put in the private area of the class. The prototypes for the interface functions should be in the public area of the class.

Data Section

You can easily identify the variables that make up the data section from the fact that all of the functions use these variables. You should remember from the lecture material on classes that the data section should be the private section of the class. You should also note that if a variable should not have direct access to it then it should be in the private section. What I mean here is that if a person can directly access a variable from a function outside of the class and if modifying this variable can cause unknown problems to the operation of your class then it should be in the private section of the class.

Prototype Functions

All of the function prototypes should also go in the class. If a function is an interface into the class then it should go in the public section. For this assignment all functions are interfaces so all prototypes should go in the public section of the class.

In the previous step you prototyped all of the functions and put them in the public section of the class definition. The bodies for these functions should go in ToDoList.cpp. Don't forget to use the scope resolution operator to relate the function bodies to the prototypes in the class definition.

Constructors

You should have a default and overloaded constructors. The overloaded constructor should take 2-strings and an int which represent the descrition, dueDate, and priority.

In: Computer Science

Information Systems Business Risks"   Identify the risks related to information systems and suggest ways to minimize...

Information Systems Business Risks"  

Identify the risks related to information systems and suggest ways to minimize them.

Describe Quality Assurance and Quality Control. Discuss their roles in information systems.

In: Computer Science

WRITE IN PERL Creating a Perl Product Directory - A product "id" will be used to...

WRITE IN PERL

Creating a Perl Product Directory - A product "id" will be used to identify a product (the key) and the description will be stored as the value

  • The program should print a menu asking you to "add" an entry, "remove" an entry, "lookup" an entry, "list" all entries, and "quit" to end
  • The user will enter a number to select the menu item from above, 1, 2, 3, 4, or 5 respectively.
  1. Asks the user to enter a product ID, then asks them to enter a description... the product ID is stored as the key of a hash and the description is the value
  2. Asks the user to an ID, if that ID exists in the hash, that entry is deleted from the hash
  3. Asks the user to an ID, if that ID exists in the hash, that entry's value is printed (the description)
  4. Prints all the key/value pairs of the hash, each entry on a new line with with a colon or dash separating the ID from the description
  5. Exits the program
  • The program will continuously loop, that is, it will print the menu after each successful action... unless the user chooses 5 to quit, which will end the program. This can be achieved by either using a "while" loop or by using a subroutine that prints the menu after each successful action

Here is a template:

#!/usr/bin/perl
use warnings;

%products = (); # empty hash to store products in

sub getChoice(){
print("Welcome to the Product Directory\n");
print("1. Add a Product to Directory\n");
print("2. Remove a Product from Director\n");
print("3. Lookup a Product in Directory\n");
print("4. List all products\n");
print("5. Quit\n");
print("Enter your option: ")
chomp($choice = <STDIN>);
return $choice
}

$c = getChoice();
while($c ne "5"){
if($c eq "1"){
# Ask the user to enter input for a product's ID
# Ask the user to enter input for a product's description
# Add the item to the hash with the supplied ID as the key and description as the value
}
  
# Options 2 - 4
}

In: Computer Science