Questions
In racket Assume that the elements of a list are indexed starting with 1. Write a...

In racket

Assume that the elements of a list are indexed starting with 1. Write a function alts that takes a list of integers xs and returns a pair of lists, the first of which has all the odd-indexed elements (in the same relative order as in xs) and the second of which has all the even-indexed elements (in the same relative order as in xs).

Output should be

(alts (list 7 5 4 6 9 2 8 3)) '((7 4 9 8)5 6 2 3)

(alts (list 5 4 6 9 2 8 3)) '((5 6 2 3) 4 9 8)

Any help would be appreciated, we're not allowed to use cond

In: Computer Science

• Using the Scanner class to obtain input from the user. • Using printf to output...

• Using the Scanner class to obtain input from the user. • Using printf to output information to the user. • Using arithmetic operators to perform calculations. • Using if statements to make decisions based on the truth or falsity of a condition. • Using relational operators to compare variable values. Project 1: Write an application that asks the user to enter two integers, obtains them from the user and prints their sum, product, difference and quotient (division). Sample Output: CSC 110 Lab 4 Page 1 of 3 Project 2. Write an application that asks the user to enter two integers, obtains them from the user and displays the larger number followed by the words “is larger”. If the numbers are equal, print the message “These numbers are equal”

In: Computer Science

Java. If possible please put explanations for each line of code. Write a test program that...

Java. If possible please put explanations for each line of code.

Write a test program that prompts the user to enter a series of integers and displays whether the series contains runLength consecutive same-valued elements. Your program’s main() must prompt the user to enter the input size - i.e., the number of values in the series, the number of consecutive same-valued elements to match, and the sequence of integer values to check. The return value indicates whether at least one run of runLength elements exists in values. Implement the test program as part of the NConsecutive class (the main() method is already in place at the end of the class).

Enter the number of values: 3
How many consecutive, same-valued elements should I look for? 3
Enter 3 numbers: 5 5 5
The list has at least one sequence of 3 consecutive same-valued elements
Enter the number of values: 3
How many consecutive, same-valued elements should I look for? 4
Enter 3 numbers: 5 5 5
The list has no sequences of 4 consecutive same-valued elements

In: Computer Science

C++: Write a program that produces truth tables for the following compound propositions. Write the header...

C++:

Write a program that produces truth tables for the following compound propositions. Write the header of the tables, including intermedial steps and the final result. There should be three tables. Output the result on the file prog2 output.txt.

1. p&!(p|q)

2. (p|q)&!(p&q)

3. (p–>q)<->(!q–>!p)

NOTE: Do not hard code truth tables. The program must use binary or bitwase operators to compute the results.

In: Computer Science

How were the original Internet requirements met through its design? What are the two main requirements...

How were the original Internet requirements met through its design? What are the two main requirements that you see missing from the original design that

are much needed today?

In: Computer Science

Enumerations Create an advanced enumeration to represent months (JANUARY – DECEMBER) called enuMonths Add internal properties...

Enumerations

  1. Create an advanced enumeration to represent months (JANUARY – DECEMBER) called enuMonths
    1. Add internal properties to represent a month.
      1. friendlyName                ( e.g., January, February, etc. )
      2. shortName                   ( e.g., Jan, Feb, etc. )
      3. monthNumber              ( e.g., 1, 2, etc. )
      4. daysInMonth                ( e.g., 31, 28, etc. )
      5. isLeapYearMonth          ( e.g., false, true, etc. )
  2. Create an advanced enumeration for a deck of cards in a game of blackjack called enuCards ( AH, 2H, 3H, etc… )
    1. Add the internal properties
      1. friendlyName                ( e.g., Ace of Hearts, 2 of Diamonds, etc. )
      2. minPointValue              ( e.g., 1, 2, etc. )
      3. maxPointValue             ( e.g., 11, 2, etc. )

  1. Create an advanced enumeration of your own. You can decide the subject and the properties it stores.  You can also add public methods to the enumeration that perform a task or calculation.

Interfaces

  1. Create an interface that would apply to all vending machines called iVendingMachine.  You will need to come up with the methods on your own that will be applied to anything that interfaces with the iVendingMachine interface
  2. Create an interface for an automobile called iAutomobile. This interface should cover what any automobile would need to implement.

In: Computer Science

The birthday paradox says that the probability (chance) that two people in a room will have...

The birthday paradox says that the probability (chance) that two people in a room will have the same birthday is more than half as long as n, the number of people in the room, is more than or equal to 23. This property is not really a paradox, but many people find it surprising. Write a Java program that generates 10 sets of 23 valid birthdays (ignore leap years). Check how many times the Birthday Paradox occurs and keep count of it. ONLY using arraylist please in java

In: Computer Science

#include <iostream> #include "lib.hpp" using namespace std; int main() {    // declare the bool bool...

#include <iostream>

#include "lib.hpp"

using namespace std;

int main() {

  

// declare the bool

bool a = true;

bool b= true;

  

//Print the Conjunction function

cout<<"\n\nConjunction Truth Table -"<<endl;

cout<< "\nP\tQ\t(P∧Q)" <<endl;

cout<< a <<"\t"<< b <<"\t"<< conjunction(a,b) <<endl;

cout<< a <<"\t"<< !b <<"\t"<< conjunction(a,!b) <<endl;

cout<< !a <<"\t"<< b <<"\t"<< conjunction(!a,b) <<endl;

cout<< !a <<"\t"<< !b <<"\t"<< conjunction(!a,!b)<<endl;

  

//Print the Disjunction function

cout<<"\n\nDisjunction Truth Table -"<<endl;

cout<< "\nP\tQ\t(PVQ)" <<endl;

cout<< a <<"\t"<< b <<"\t"<< disjunction(a,b) <<endl;

cout<< a <<"\t"<< !b <<"\t"<< disjunction(a,!b) <<endl;

cout<< !a <<"\t"<< b <<"\t"<< disjunction(!a,b) <<endl;

cout<< !a <<"\t"<< !b <<"\t"<< disjunction(!a,!b)<<endl;

  

  

//Print the ExclusiveOr function

cout<<"\n\nExclusiveOr Truth Table -"<<endl;

cout<< "\nP\tQ\t(P⊕Q)" <<endl;

cout<< a <<"\t"<< b <<"\t"<< exclusiveOr(a,b) <<endl;

cout<< a <<"\t"<< !b <<"\t"<< exclusiveOr(a,!b) <<endl;

cout<< !a <<"\t"<< b <<"\t"<< exclusiveOr(!a,b) <<endl;

cout<< !a <<"\t"<< !b <<"\t"<< exclusiveOr(!a,!b)<<endl;

  

  

//Print the Negation function

cout<<"\n\nNegation Truth Table -"<<endl;

cout<< "\nP\t~P" <<endl;

cout<< !a <<"\t" << negation(!a)<<endl;

cout<< a <<"\t" << negation(a) <<endl;

How can u do this code Using the enum keyword or a C++ class? To create a new type Boolean with the two values F and T defined.

In: Computer Science

Parallel Arrays This question is in MindTap Cengage Summary In this lab, you use what you...

Parallel Arrays

This question is in MindTap Cengage

Summary

In this lab, you use what you have learned about parallel arrays to complete a partially completed C++ program. The program should:

Either print the name and price for a coffee add-in from the Jumpin’ Jive Coffee Shop

Or it should print the message Sorry, we do not carry that.

Read the problem description carefully before you begin. The file provided for this lab includes the necessary variable declarations and input statements. You need to write the part of the program that searches for the name of the coffee add-in(s) and either prints the name and price of the add-in or prints the error message if the add-in is not found. Comments in the code tell you where to write your statements.

Instructions

Study the prewritten code to make sure you understand it.

Write the code that searches the array for the name of the add-in ordered by the customer.

Write the code that prints the name and price of the add-in or the error message, and then write the code that prints the cost of the total order.

Execute the program by clicking the "Run Code" button at the bottom of the screen. Use the following data:

Cream

Caramel

Whiskey

chocolate

Chocolate

Cinnamon

Vanilla

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

This is what i have so far:

// JumpinJava.cpp - This program looks up and prints the names and prices of coffee orders.
// Input: Interactive
// Output: Name and price of coffee orders or error message if add-in is not found

#include <iostream>
#include <string>
using namespace std;

int main()
{
   // Declare variables.
   string addIn;     // Add-in ordered
   const int NUM_ITEMS = 5; // Named constant
   // Initialized array of add-ins
   string addIns[] = {"Cream", "Cinnamon", "Chocolate", "Amaretto", "Whiskey"};
   // Initialized array of add-in prices
   double addInPrices[] = {.89, .25, .59, 1.50, 1.75};
   bool foundIt = false;     // Flag variable
   int x;          // Loop control variable
   double orderTotal = 2.00; // All orders start with a 2.00 charge
   int findItem();
   // Get user input
   cout << "Enter coffee add-in or XXX to quit: ";
   cin >> addIn;
  
   // Write the rest of the program here.
    findItem();
        foundIt = false
        x = 0
        while(x < NUM_ITEMS)
            if addIn = addIns[x]
                foundIt = true
                orderTotal = addInPrices[x]
            endif
            x = x + 1
        endwhile
        if(foundIt = true)
        {
            cout << "The price of" << addIns[x] << "is" << addInPrices[x] << "." << endl;
        }
        else
        {
            cout << "Sorry, we do not carry that." << endl;
        }
   return 0;
} // End of main()

In: Computer Science

JAVA Write a test program that prompts the user to enter a series of integers and...

JAVA

Write a test program that prompts the user to enter a series of integers and displays whether the series contains runLength consecutive same-valued elements. Your program’s main() must prompt the user to enter the input size - i.e., the number of values in the series, the number of consecutive same-valued elements to match, and the sequence of integer values to check. The return value indicates whether at least one run of runLength elements exists in values. Implement the test program as part of the NConsecutive class (the main() method is already in place at the end of the class).

I am looking for a fix of my current code for this question. My code executes the expected output, but it messes up with other outputs. For example, if I input this data:

Enter The Number of Values: 5
How many consecutive, same-valued elements should I look for?: 2
Enter 5 Numbers: 1 1 2 2 1 1
The list has no sequence of 2 consecutive same-valued elements

The output I should get is "The list has at least 1 sequence of 2 consecutive same-valued elements"

EXPECTED OUTPUT:

Enter the number of values: 3
How many consecutive, same-valued elements should I look for? 3
Enter 3 numbers: 5 5 5
The list has at least one sequence of 3 consecutive same-valued elements
Enter the number of values: 3
How many consecutive, same-valued elements should I look for? 4
Enter 3 numbers: 5 5 5
The list has no sequences of 4 consecutive same-valued elements

CURRENT CODE:

public static boolean hasNConsecutive( int[] values, int runLength ) {
       int count = 0;
       for (int i = 0; i < (values.length-1);i++)
       {
           if (values[i] == values[i + 1]) {
               count++;
               if(count == runLength)
                   break;
           }
           else {
               count = 0;
       }
   }
   if (count >= (runLength - 1))
       return true;
   else
   return false ;
}   // end hasNConsecutive()
   public static void main( String[] args ) {
       int x, runLength;
      
       Scanner input = new Scanner(System.in);
      
       System.out.printf("Enter The Number of Values: ");
       x = input.nextInt();
      
       int values[] = new int[x];
       System.out.printf("How many consecutive, same-valued elements should I look for?: ");
       runLength = input.nextInt();
       System.out.printf("Enter "+ x + " Numbers: ");
       for(int i = 0; i < x; i++) {
           values[i] = input.nextInt();
       }
       input.close();
       if(hasNConsecutive(values,runLength))
           System.out.println("The list has at least one sequence of " + runLength + " consecutive same-valued elements");
       else
           System.out.println("The list has no sequence of " + runLength + " consecutive same-valued elements");
       }

   }

In: Computer Science

(2) Cite an example on how organizations like Google, Facebook, Youtube etc collect data for image...

(2) Cite an example on how organizations like Google, Facebook, Youtube etc collect data for image identification, email classification, mature content and cyber bullying. (Give one example for each).

In: Computer Science

In C++ Having call-by-reference allows one to use storeback parameters, i.e., parameters whose values are transmitted...

In C++

Having call-by-reference allows one to use storeback parameters, i.e., parameters whose values are transmitted back to their arguments. In this exercise, you are to write a program that provides several variations of a function that calculates the minimum of two values. Several of the functions also report whether the two values passed in were equal. The functions are all named min — they differ in their arguments and return values:

  • Accept two integers and return their minimum
  • Accept three parameters: two integers, and a third integer storeback set to the minimum of the first two. Return a boolean set to true if the inputs are not equal, and false otherwise.
  • Accept three parameters: two integers, and a boolean storeback set to true if they are not equal and false otherwise. Return an integer set to the minimum of the two inputs.
  • Accept four parameters: two integers, a boolean storeback set to true if they are not equal and false otherwise, and another integer storeback set to the minimum of the two.

Call the file min.cpp. In the same file, write a main function demonstrating use of the above functions. The app should accept pairs of integers from the console (until eof), call each of the function sand print out the results using the format illustrated below:

Sample test run:

first number? 3
second number? 4
int min(x, y): The minimum of 3 and 4 is 3
bool min(x, y, min): The minimum of 3 and 4 is 3
int min(x, y, ok): The minimum of 3 and 4 is 3
void min(x, y, ok, min): The minimum of 3 and 4 is 3

first number? 5
second number? 2
int min(x, y): The minimum of 5 and 2 is 2
bool min(x, y, min): The minimum of 5 and 2 is 2
int min(x, y, ok): The minimum of 5 and 2 is 2
void min(x, y, ok, min): The minimum of 5 and 2 is 2

first number?

In: Computer Science

“Triangle Guessing” game in Python The program accepts the lengths of three (3) sides of a...

Triangle Guessing” game in Python

The program accepts the lengths of three (3) sides of a triangle as input . The program output should indicate if the triangle is a right triangle, an acute triangle, or an obtuse triangle.

  1. Make sure each side of the triangle is a positive integer. Use try/except for none positive integer input.
  2. validating the triangle. That is the sum of the lengths of any two sides of a triangle is greater than the length of the third side. Use try/except for invalid sides input.
  3. For any wrong input, tell the player what is wrong and asking to re-enter.
  4. Allow a player to play multiple times, for example, using a while loop. Remind the player what input to stop the game.
  5. user friendly one.
  6. add comments:
    1. Introduce/describe the program including the author, date, goal/purpose of the program
    2. Document every variable used at the program even the name is meaningful
    3. Explain/comment operation/activity/logic of your code. For example, “Checking whether the inputs are positive integers” and “Checking the validity the 3 lengths to see if they are able to form a triangle”
  7. Testing your program for all possible input and every of the 3 possible triangles

In: Computer Science

THIS PROGRAM HAS TO BE WRITTEN IN C Single function to perform the parity computation on...

THIS PROGRAM HAS TO BE WRITTEN IN C

Single function to perform the parity computation on the input integer passed to this function. The output of the function is 0 if the input has even parity (that is, the number of 1s in the binary representation of the input is even) and 1 if the input has odd parity (that is, the number of 1s in the binary representation of the input is odd).

In: Computer Science

1) Alternative compiled code sequence using instructions in classes A, B, C. What is the average...

1) Alternative compiled code sequence using instructions in classes A, B, C. What is the average CPI of sequence 1 and sequence 2?

class A B C

CPI for class 3 4 6

IC in Sequence 1 6 12 10

IC in sequence 2 2 4 2

2) given the 8-bit binary number 1011 1110 (two's compliment, we will call this number N)

a) what is the hEX representation of N

b) what is the decimal value if N is an 8-bit 2's compliment signed number?(please write steps

c)what is the decimal value if N is an 8-bit unsigned number?

In: Computer Science