Questions
JAVA: Display all even numbers between 1 and 20 --Optional write a program that reads in...

JAVA:

Display all even numbers between 1 and 20

--Optional write a program that reads in 20 numbers. A method with an int parameter should display whether the number is odd or even for the number passed

In: Computer Science

QUESTION 1a A valid selection must be between 0 and 4. Enter the program below and...

QUESTION 1a

A valid selection must be between 0 and 4. Enter the program below and complete the while loop. Name the program question1.cpp, compile and run it.
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
// Fill in the code to define an integer variable called selection
cout << "Please enter the choice of ticket "
<< "(a number from 1 to 4 or 0 to quit) " << endl;
cout << "Ticket Menu " << endl << endl;
cout << "1: Exclusive VIP area A " << endl;
cout << "2: VIP area B " << endl;
cout << "3: Elevated area " << endl;
cout << "4: General area R600 " << endl;
cout << "0: QUIT " << endl <<endl << endl;
cin >> selection ;
while (…………………) //complete the condition

{
cout << “Invalid choice – Please re-enter “;
cin >> selection;
}
cout << “You have selected option number “ << selection;
return 0;
}

QUESTION 1b

Modify question1.cpp by adding the code to calculate the cost per order. Make use of a switch statement.
cout << "You have selected option number "“ <<;
cout << "How many tickets would you like?" << endl;
// Fill in the code to read in number
// Fill in the code to begin a switch statement
// that is controlled by selection
{
case 1: cost = number * 3000;
cout << "The total cost is R " << cost << endl;
break;
// Fill in the code for the case VIP area B ( R2000.00 each)
// Fill in the code for the case Elevated area (R1200.00 each)
// Fill in the code for the case General area (R600.00 each)
case 0: cout << " Please come again" << endl;
break;
default:
cout << “Invalid selection”
cout << " Try again please" << endl;
}

In: Computer Science

C++ programming: FUNCTIONS WITH DIFFERENT RETURN TYPES AND PARAMETERS NuMetro has a special on movies for...

C++ programming: FUNCTIONS WITH DIFFERENT RETURN TYPES AND PARAMETERS

NuMetro has a special on movies for all members of the public but special discounts for students and pensioners. If pensioners or students buy a movie ticket they receive 10% if they buy a movie and popcorns, they receive 20% discount. Other customers only receive a discount when they buy a movie ticket and popcorn; there is no discount for just a movie ticket alone. Write a program named question5b.cpp that will consist of two functions. The program must prompt the user for type of customer (‘p’ for pensioner, ‘s’ for student, ‘o’ for other). It must then call the relevant function according to that entry. The first function must receive the customer type and calculates discount for pensioners and students. The second function calculates the discount for customers that are not pensioners or students.

In: Computer Science

a) What are the most important principals for designing a good report or visual? b) What...

a) What are the most important principals for designing a good report or visual?

b) What would you specifically avoid in designing a good report or visual?

In: Computer Science

C++ Question 4. Formulate the following conditions • A last name starts with the letter H....

C++ Question

4. Formulate the following conditions

• A last name starts with the letter H.

• A last name starts with the letters Mac.

• A last name comes before "Jones".

In: Computer Science

Show that if all nodes in a splay tree are accessed in sequential order, then the...

Show that if all nodes in a splay tree are accessed in sequential order, then the
total access time is O(N), regardless of the initial tree.

In: Computer Science

5.16 Implement function indexes() that takes as input a word (as a string) and a onecharacter...

5.16 Implement function indexes() that takes as input a word (as a string) and a onecharacter letter (as a string) and returns a list of indexes at which the letter occurs in the word.

>>> indexes('mississippi', 's')

[2, 3, 5, 6]

>>> indexes('mississippi', 'i')

[1, 4, 7, 10]

>>> indexes('mississippi', 'a')

[]

In: Computer Science

Explain how the modular kernel design combines the benefits of both the layered and microkernel structures.

Explain how the modular kernel design combines the benefits of both the layered and microkernel structures.

In: Computer Science

make a python script that has the following typed: school = “cochise college” place = “online”...

make a python script that has the following typed:

school = “cochise college”

place = “online”

Then do the following with the given parameters.Set the script to have a function that takes two parameters, school and place, have your function return the first 5 characters of each parameter value, utilizing a slice. Change the script to have a function that takes two parameters, school and place, have your function return the first character of each parameter, utilizing an index value. Then, Modify the script to have a function that takes two parameters, school and place, have your function return the last character of the variable place for each parameter, utilizing an index value. Next, modify the script to have a function that takes two parameters, school and place, have your function return the variables school and place in title form. Lastly, modify the python script to have a function that takes two parameters, school and place, have your function check to verify that ‘cochise’ is in the school parameter and ‘online’ is in the place parameter. If it is have the function return, ‘Great you go to Cochise College Online!’, else have the function return, ‘You should check out Cochise College Online!’

In: Computer Science

The objective is to read the last five lines of a file (text file) in Perl....

The objective is to read the last five lines of a file (text file) in Perl. I wrote down what I have written so far in Perl but I get an error message saying, "Can't open sample.txt: No such file or directory." The sample.txt file is located in the same directory that I am executing the perl scripts on the command line.

sample.txt

=============================================================

My
name
is
Jennifer
and
I
like
to
eat
tacos
de
birria
.

===========================================================

#!/usr/bin/perl

$filename= 'sample.txt';

open my $fh, "+>", $file or die "Can't open $filename: $!\n";

print "$file[-5]\n";

print "$file[-4]\n";

print "$file[-3]\n";

print "$file[-2]\n";

print "$file[-1]\n";

In: Computer Science

I'm doing a practice test and I can't seem to find the answers anywhere for these...

I'm doing a practice test and I can't seem to find the answers anywhere for these specific questions. If someone could please help clarify so I can learn that would be helpful!

1. Identify the true statements. Select ALL that apply.


a. Setters and getters are not required for public instance variables.

b. A setter method is return-type void and takes a parameter of the same type as its field.

c. A getter method has the same return-type as the field it retrieves and takes no parameters.

d. Every private instance variable in a class definition must have a mutator method.

2.
private char gender;public class Person {

static int number;

//...

public static void main(String[] args) {

Person person;

   //...

}

public static void callPerson(int hours) {

double payRate = 24.99;

}

}

The code above compiles okay. Refer to it to complete this matching exercise.

_____

person

_____

hours

_____

number

_____

payRate

_____

gender

1.

local reference variable

2.

class variable

3.

instance variable

4.

parameter

5.

local primitive variable


3. Identify the true statements. Select ALL that apply.

a. Static methods are also class methods

b. Static methods of a class can be called without instantiating the class.

c. A static method cannot access the data members of its own class.

d. A non-static method can be called from a static method.

4. What does the public visibility modifier mean?

a. means accessible from any class in the same package.

b. means accessible to the current program.

c. means accessible to any method in the class.

d. means accessible from any other classes.

5.

3. public class Person {
4. private double salary;
5. public Person() {
6. salary = 1000.0;
7. }

What type of constructor is illustrated by lines 5 through 7?


6. Identify the true statements. Select ALL that apply.

a. Constants in a class should be declared as final static.

b. Static variables and static methods of a class can be accessed by an object of that class and by the class name.

c. Static variables have a default value of null.

d. Anonymous objects are possible in Java.


7. What Java keyword sometimes used in a class definition refers to the class itself?

In: Computer Science

This program does password verification. It gives the user three attempts to type in the correct...

This program does password verification. It gives the user three attempts to type in the correct password. Assume that the password is "COMSC110" (You can hard-code this). If the user types in the correct password, display a message saying "Login successful" and break out of the loop, otherwise display " Login Failed" and go to the next iteration. If the user enters three unsuccessful entries, then display a message saying " Too many attempts, Try again later", Use a while loop.

In: Computer Science

Write a program to simulate a calculator. Generate two random numbers (between 1-15) and an ask...

Write a program to simulate a calculator. Generate two random numbers (between 1-15) and an ask the user for an arithmetic operator. Using a switch statement, your program has to perform the arithmetic operation on those two operands depending on what operator the user entered. Ask the user if he/she wants to repeat the calculations and if the answer is yes or YES, keep repeating. If the answer is something else, then stop after the first calculation. c++

In: Computer Science

Write a program that prints the question “Do you wish to continue?” and reads the input....

Write a program that prints the question “Do you wish to continue?” and reads the input. If the user input is “Y”, “Yes”, “YES”, then print out “Continuing”. If the user input is “N” or “No”, “NO” then print out “Quit”. Otherwise, print “Bad Input”. Use logical operators. c++

In: Computer Science

Given the following relational schema, write queries in SQL to answer the English questions. There is...

Given the following relational schema, write queries in SQL to answer the English questions. There is a shipment database on the MySQL server. You can also use the DDL for MySQL. You must only submit the SQL for your answers but you can include the query output as well to help the TA with marking.

Customer(cid: integer, cname: string, address: string, city: string, state: string)
Product(pid: integer, pname: string, price: currency, inventory: integer)
Shipment(sid: integer, cid: integer, shipdate: Date/Time)
ShippedProduct(sid: integer, pid: integer, amount: integer)
  1. Return customer names and total sales of products shipped to each customer. Only show customers with total sales of over $200with the results ordered in descending order of total sales.

    Output:

    +-----------------+-------------+
    | cname           | total_sales |
    +-----------------+-------------+
    | Joe Smithsonian |     2427.80 |
    | Russell Johnson |     1057.68 |
    | Scott Charles   |      260.00 |
    +-----------------+-------------+

In: Computer Science