WRITTEN IN C PLEASE.
Write a switch statement that tests the value of the char variable response and performs the following actions: if response is y, the message Your request is being processed is printed if response is n, the message Thank you anyway for your consideration is printed if response is h, the message Sorry, no help is currently available is printed for any other value of response, the message Invalid entry; please try again is printed
In: Computer Science
Consider a discrete fully observable world with S states. How many distinct simple reflex agents, each with A actions, can be written for such a world? Two agents are distinct if there exists some world state where they take different actions.
In: Computer Science
Assignment #2*: Build A Report Purpose: Exercise, use, Inputs, Outputs, and perform conditional evaluation Requirements: (Multiple classes/Multiple types of input) • Input: Report Owner’s full name and 7 numbers (at least one double and one integer) o The owner’s name cannot contain any special characters, blank spaces, or numbers • You must use an if statement and at least one switch statement in your program • You are not allowed to have static variables or methods in any class except for the class with the main method. • You have to have at least 2 classes • You are not allowed to use ArrayLists or Vectors, only primitive arrays or string arrays if you want. Application Operation: 1.) Input, via a question in the console, the report owner’s first name as a string and build the last name via input, one character at a time. a. Check, conditionally, to make sure the first name and last name don’t contain any numeric characters, numbers between 0 – 9. If it does you must remove it. The names can not contain any white space either or special characters. 2.) Input report name via a request from the console. 3.) Input, and display, the total of the numeric input after each input is entered. Average the numeric input, indicate lowest numeric input value and the highest numeric input value for the previous numeric inputs, before the next numeric input is asked for. (Example given in class) 4.) Have a program exit input, condition, value available (i.e. if you type -1 the program exits) 5.) Create and display a final report that should have the report name, owner and the following: Numeric output should appear as a table with the following columns: (columns should be underlined) a. Input Number b. Highest Number c. Lowest Number d. Total (by the row) e. Average Number 6.) At the end of the report you must have a grand total for the numeric entries
In: Computer Science
Develop a C# console application that will implement one method that will return an integer value, one void method that will calculate an average, and one void overload for the calculate method that will compute a total. Please read the requirements below carefully. In Main: You will need four variables: an integer value to hold a random value, a double value to hold an average, a double value to hold a total, and a double value to hold an input entry. Using a for loop that will call a get random method 20 times. In the loop, you will pass a seed value to the get random method to use with the random generator and it will return a random value to be added to (accumulate) to the local integer variable in Main. In the getRandommethod, you will generate a random value between 1 and 100 (see p241, section 7.9) and return that random value to Main. The random value will be generated to get random using a Random class object. Once the loop has completed the 20 method calls you will call a calculate method which returns no value and to which you will pass the total of the random values, the average variable by reference, and the literal value of 20. In the calculate method you will compute an average by dividing the total of the random number passed in by the literal value 20 that was passed into the calculate method. After the calculation method executes you will display the average to the console. Following the writeline statement noted above, you will implement a second for loop that will process 5 iterations. Within this for loop you will prompt the user to enter a double value from the console and then assign that input to the double variable declared to hold the input entry. Also within the loop you will call an overload of the void calculate method and will pass two arguments: the entry taken from the console and the variable to hold the total by reference. The overload of the void calculate method will receive the double entry value and the byref double variable that will receive the total. In the overloaded calculate method you will add the value passed in to the total variable. After the overloaded calculate method executes you will display the total to the console. and I want the screenshot of the output too.
In: Computer Science
JAVA - Complete the directions in the 5 numbered comments
import java.util.Scanner;
/**
* This program will use the HouseListing class and display a list of
* houses sorted by the house's listing number
*
* Complete the code below the numbered comments, 1 - 4. DO NOT CHANGE the
* pre-written code
* @author
*
*/
public class HouseListingDemo {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
HouseListing[] list;
String listNumber, listDesc;
int count = 0;
double listPrice;
String output;
double mostExpensive;
do{
System.out.print("Enter the number of houses --> ");
count = scan.nextInt();
}while(count < 1);
/* 1.
* create an array of HouseListing objects using the variable that holds
* the user's response to the prompt above
*/
// for loop loads the array with HouseListing's constructor
for (int i = 0; i < list.length; i++)
{
System.out.println("\n***HOUSE " + (i+1) + "***");
// Prompt for house listing #
System.out.print("Enter house listing " +
"number (Alphanumeric) #"+ (i+1) +": ");
listNumber = scan.next();
// Clear buffer
scan.nextLine();
// Prompt for house description
System.out.print("Enter description for " +
"house #" +(i+1) + ": ");
listDesc = scan.nextLine();
// Prompt for house price
System.out.print("Enter listing price for "
+ "house #" +(i+1) + ": ");
listPrice = scan.nextDouble();
/* 2.
* create a HouseListing object using the input values and store/load
* the object in the array
*/
}
/* 3.
* Assign the 0th element of the array to the most expensive house
think ... you can't assign an object to a price but the object
has a method that may help you here ...
*/
output = "Listings:\n";
/*
* loop below builds the output string
*/
for (int i = 0; i < list.length; i++) {
output += list[i] + "\n";
/* 4.
Using a control structure, find and the store the double varaible
which holds the most expensive house (We don't need to listing #)
JUST THE PRICE
*/
}
// output
System.out.println(output);
System.out.println("The most expensive house on the market costs: $"
+ mostExpensive);
}
}In: Computer Science
A group of 2 n 1 routers are interconnected in a centralized
binary tree, with a router ateach tree node. Router i communicates
with router v by sending a message to the root of the tree. The
root then sends the message back down to u. Derive an expression
for the average number of hops per message for a router to
communicate with another router. You do not have to simplify the
expression derived. Hint. Use the height of a router from the root
the tree.
In: Computer Science
(a) Consider the following MIPS memory with data shown in hex, which are located in memory from address 0 through 15. Show the result of the MIPS instruction “lw $s0, 4($a0)” for machines in little-endian byte orders, where $a0 = 4.
|
Address |
Contents |
|
0 |
8a |
|
1 |
9b |
|
2 |
a3 |
|
3 |
b4 |
|
4 |
c5 |
|
5 |
6d |
|
6 |
7e |
|
7 |
8f |
|
Address |
Contents |
|
8 |
0a |
|
9 |
1b |
|
10 |
2c |
|
11 |
3d |
|
12 |
4e |
|
13 |
5f |
|
14 |
66 |
|
15 |
70 |
(b) )Assume we have the following time, performance and architecture parameters in the specified units.
Ec = execution time in cycles/program
Es = execution time in seconds/program
Pr = performance rate in instructions/seconds
CCT = clock cycle time in second/cycle
CR = clock rate in cycle/second
IC = instructions in instructions/program
CPI = average cycles per instruction in cycle/instruction
Complete the following formulas with the appropriate parameter
CR = 1/____, ____ = IC´ CPI, Es = ____ ´ CPI ´ CCT
In: Computer Science
Write a C++ program that uses a de-duplication function that iteratively sanitizes (removes) all consecutive duplicates in a C++ string. Consecutive duplicates are a pair of duplicate English alphabets sitting next to each other in the input string. Example: "AA", "KK", etc., are all consecutive duplicates. This function will internally run as many iterations as needed to remove all consecutive duplicates until there is either no consecutive duplicates left, or the string becomes empty (in which the function returns "Empty" back to the user):
string deduplicate(string input)
Your main() may look like the following, or anything you prefer to put in it as it is not graded:
int main() {
cout << deduplicate("AABB"); // should output "Empty"
cout << deduplicate("A"); // "A"
cout << deduplicate("ABBA"); // should output "Empty"
cout << deduplicate("AAA"); // "A"
cout << deduplicate("AKA"); // "AKA" because there is no consecutive pair.
return 0;
}
-----------------------------------------------------------
Examples:
-----------------------------------------------------------
Constraints/Assumptions:
In: Computer Science
Write the following questions as queries in SQL. Use only the operators discussed in class (no outer joins)
Consider the following database schema:
INGREDIENT(ingredient-id,name,price-ounce)
RECIPE(recipe-id,name,country,time)
USES(rid,iid,quantity)
where INGREDIENT lists ingredient information (id, name, and the price per ounce); RECIPE lists recipe information (id, name, country of origin, and time it takes to cook it); and USES tells us which ingredients (and how much of each) a recipe uses. The primary key of each table is underlined; rid is a foreign key to RECIPE and iid is a foreign key to INGREDIENT
Write the following queries in SQL.
1. Find the names of French recipes that use butter and take longer than 45 minutes to cook.
2. Find the names of recipes that use butter or lard.
3. Find the names of recipes that use butter and lard.
In: Computer Science
Question 1)
The Following OOP Problem must be completed in C++
Consider a bubble gum dispenser.The dispenser releases one bubble gum at a time until empty. Filling of the dispenser adds a positive number of bubble gums.
A) Write an Abstract Data Type for a bubble gum dispenser
B) Draw the UML class diagram
C) Define a C++ class for a bubble gum dispenser object
D) The number of bubble gums in the dispenser is private
E) Write an implementation for the class
F) Write a simple test program to demonstrate that your class is implemented correctly
In: Computer Science
5.9 Online shopping cart (Java)
Create a program using
classes that does the following in the zyLabs developer below. For
this lab, you will be working with two different class files. To
switch files, look for where it says "Current File" at the top of
the developer window. Click the current file name, then select the
file you need.
(1) Create two files to submit:
Build the ItemToPurchase class with the following specifications:
(2) In main(), prompt
the user for two items and create two objects of the ItemToPurchase
class. Before prompting for the second item, call
scnr.nextLine(); to allow the user to input a new
string. (2 pts)
Ex:
Item 1 Enter the item name: Chocolate Chips Enter the item price: 3 Enter the item quantity: 1 Item 2 Enter the item name: Bottled Water Enter the item price: 1 Enter the item quantity: 10
(3) Add the costs of the two items together and output the total
cost. (2 pts)
Ex:
TOTAL COST Chocolate Chips 1 @ $3 = $3 Bottled Water 10 @ $1 = $10 Total: $13
In: Computer Science
need this in C++
Start
Declarations
number currentTuition
number futureTuition
number interestRate
number numYears
number year
output "Please enter current tuition: "
input currentTuition
output "Please enter interest rate (e.g. 9.0 for 9 percent): "
input interestRate
output "Please number of years for tuition: "
input numYears
output “Tuition at year 1 is “, currentTuition
futureTuition = currentTuition
for year = 2 to numYears
futureTuition = futureTuition * (1 + interestRate/100)
output “Tuition at year “, year ,”is “, futureTuition
endfor
Stop
In: Computer Science
In: Computer Science
Let a , b , c be three integer numbers. Write a C++ program with a functions
void rotate1(int* a,int* b,int* c)
void rotate2(int& a,int& b,int& c)
such that a -> b , b -> c and c -> a. Thus we use two different approaches (pointers in rotate1 and references in rotate2).
In: Computer Science
The threat on the Texas power grid has escalated. An imminent attack is expected coming from multiple fronts. This includes expected coordinated attacks including DDOS, malware, and physical attacks on substation equipment. To secure the grid against such an attack, formulate an effective defense scenario and strategies to counter the cyber attack. This includes deceiving, confining, and neutralizing the attackers before it actually occurs, keeping the grid up.
In: Computer Science