Questions
this should be written in Java- Problem: Min/Max Search by Index Develop a program that, given...

this should be written in Java- Problem: Min/Max Search by Index Develop a program that, given a sequence S of integers as input, produces as output two sequences of positive integers, the first of which indicates all those positions in S at which S's minimum value occurs and the second of which indicates all those positions at which S's maximum value occurs. Positions are numbered starting at zero (0).

Facts ● Scanner has a method that returns a boolean indicating whether a next integer exists in its input stream ( hasNextInt() ) ● Scanner objects can be initialized to to scan String data as input.

Sample input

3

3 6 -1 4 6 5 3

0 0 0 0

-4 45 2 0 3 5 11 -7 854 25 3 -7 4 -3

Sample output

3 6 -1 4 6 5 3

2

1 4

0 0 0 0

0 1 2 3

0 1 2 3

-4 45 2 0 3 5 11 -7 854 25 3 -7 4 -3

7 11

8

Input The input will begin with a single line containing T , the number of test cases to follow. The remaining lines contain the T sequences, one line per sequence. Each of these lines contains the values in the sequence. Each such value is separated from the next by at least one space.

Output For each sequence given as input, there should be four lines of output. The first line echos the given sequence. The second line indicates the positions at which the minimum value occurs. The third line indicates the positions at which the maximum value occurs. The fourth line is blank.

In: Computer Science

Write a javascript program that computes the total cost for a five year car lease. The...

Write a javascript program that computes the total cost for a five year car lease. The program starts with a monthly leasing amount and a yearly increase in percent. The program then outputs the total amount paid for each year and the total overall cost of the lease.

In: Computer Science

What is your opinion on the use of AI technology? Is it necessary or is it...

What is your opinion on the use of AI technology? Is it necessary or is it a step in a wrong/different direction?

In: Computer Science

please i need to have good answers and easy to understand This exercise refers to the...

please i need to have good answers and easy to understand

This exercise refers to the Develop Schedule process. Please answer the following questions.

  1. Describe the difference between crashing and fast tracking.
  2. During Schedule Development, resources are assigned to the project activities. Describe resource leveling heuristics and why and when you use this technique.
  3. What are the advantages and disadvantages of using project management software?

In: Computer Science

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