Questions
1.) Many languages (e.g., C and Java) distinguish the character ’c’ from the string “c” with...

1.) Many languages (e.g., C and Java) distinguish the character ’c’ from the string “c” with separate sets of quotation marks. Others (e.g., Python) use “c” for both single characters and strings of length one. Provide (and justify) one advantage and one disadvantage of Python’s approach.

2.The designers of Java distinguish the primitive types (scalars) from the reference types (all other types of values) in the language. Discuss the costs and benefits to the programmer of this decision

3.In Ruby, the Hash class accepts the “each” method, allowing hashes to be interacted over, like a collection. In Java, however, the Map classes are not formally part of the JCF (Java Collections Framework). For both Ruby and Java, provide (and justify) an advantage of the language’s choice of location in the class hierarchy of its form of associative list

4.What are the basic differences, if any, in how Java and Ruby handle information hiding (a.k.a. encapsulation)?

5. Java and C++ support generic collections with type parameters, whereas Ruby does not. Does that fact place the Ruby programmer at a disadvantage? Why or why not?

In: Computer Science

//draft to work from for Assignment 7 where you compute a student's quiz average, dropping two...

//draft to work from for Assignment 7 where you compute a student's quiz average, dropping two lowest scores, assuming
//they have 2 or more quizzes
// a max of 12 quizzes can be taken
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <fstream>

using namespace std;

const int NUM_QUIZZES = 12;  //assume 12 quizzes max can be taken

int buildQuizArray( int [] );   //you need to write these 5 functions below
void printQuizArray( string, int [], int );

double calcQuizAverage( int [], int );

void sortQuizArray( int [], int );
void copyArray( int [], int [], int );


int main()
{ //this is the driver code in main routine , calling your functions
int quizArray[NUM_QUIZZES];  //declare array to hold 12 quizzes
int numQuizzes;              //will be filled in with number of quizzes from buildQuizArray

numQuizzes = buildQuizArray( quizArray );  //call buildQuiz array, numQuizzes is returned from function

printQuizArray( "Quiz Scores From QuizArray After My Build Function", quizArray, numQuizzes );  //print it out to make sure it is built correctly
                                                                                    //take out when finished
cout << fixed << setprecision(2);

cout << endl << "Your quiz average is " << calcQuizAverage(quizArray, numQuizzes)
     << "%" << endl;  //call function and get a double returned to print to user

printQuizArray( "Quiz Scores From QuizArray after calling calcQuizAverage", quizArray, numQuizzes );  
                                                   //print array again to make sure you did not change the original array

return 0;
}

 //********************************************************************************

int buildQuizArray( int array[] )
{
//build the array of quizzes  and return the count of entries of the array back to main routine
}


//*************************************************************************
void printQuizArray( string reportTitle, int array[], int numValues )
{
//print out the quiz array with appropriate title passed to you in reportTitle....add  "/10" to end of each quiz score
}


//***************************************************************************

double calcQuizAverage( int array[], int numValues )
{

//if 2 or less values in array use formula in assignment sheet for 2 or less values to compute average

//if more than 2, define another "work" array in this function, call copyArray function below  to copy elements to a "work array" from array passed to you,
//and then call sortQuizArray function to sort your "work array". After work array has been sorted ascending order, use formula in sheet
// to compute the quiz average  (which will not factor in the two lowest quiz scores in positions 0 and 1 in array)

//return the average computed to the main return
}



//***********************************************************

void copyArray( int destinationArr[], int sourceArr[], int numValues )
{
//copy the data from source array into destination array with a loop
// numValues has number of entries in the array

//at the bottom of this function print out  destinationArr to make sure it is correctly copied, simply call printQuizArray
printQuizArray("Here's my copy/work array that is to be sorted: ", destinationArr ,numValues);
}
//***************************************************************
void sortQuizArray( int array[], int numValues )
{
//code selection sort logic here to sort array passed in ,  BEGIN=0, END=numValues-1
//suggestion: document each line of code here to simulate the selection sort algorithm


//at bottom of sort, to make sure table is sorted call print function and verify it is sorted
printQuizArray( "Here is my sorted array", array, numValues );  //print it out to make sure it is built correctly,take out when finished

}

In: Computer Science

Using Java, Ask for the runner’s name Ask the runner to enter a floating point number...

Using Java,

  1. Ask for the runner’s name

  2. Ask the runner to enter a floating point number for the number of miles ran, like 3.6 or 9.5

  3. Then ask for the number of hours, minutes, and seconds it took to run

  • A marathon is 26.219 miles

  • Pace is how long it takes in minutes and seconds to run 1 mile.

Example Input:
What is your first name? // user enters Pheidippides
How far did you run today? 10.6 // user enters 10.6 miles

How long did it take? Hours: 1 // user enters 1 hours

Minutes: 34 // user enters 34 minutes

Seconds: 17 // user enters 17 seconds

Example Output:

Hi Pheidippides
Your pace is 8:53 (minutes: seconds)
At this rate your marathon time would be 3:53:12
Good luck with your training!

After your program tells the user what their pace is, your program will build a table showing the following columns. The pace table should start with the fastest man time which is Eliud Kipchoge.

Example:

Pace Table
Pace Marathon
4:37 2:01:04 ←- Eliud Kipchoge
5:17 2:18:41
5:57 2:36:18
6:37 2:53:55
7:18 3:11:32
7:58 3:29:09
8:38 3:46:46
8:53 3:53:12 ← Pheidippides

  • The table should start with the World Record pace and time which is 4:37, 2:01:04.

  • Then continues in 17 minute and 37 second intervals until you reach the marathon time of the user.

  • Use a static function to print the pace table, introduce a while loop.

  • For the first person it should call a printTable function

    • Example : printTable (pace, “<--- Eliud Kipchoge”) something like that

    • The pace table continues until it reaches the user

    • printTable (myPace, name) something like that  

  • For the marathon and pace time, make sure the format has 0’s if the time is 9 seconds, it should be 09.

  • Use the printf statement for formatting output (“02d %f%s”)

In: Computer Science

Python Programming: Scrambled Word Game Topics: List, tuple Write a scrambled word game. The game starts...

Python Programming: Scrambled Word Game

Topics: List, tuple

Write a scrambled word game. The game starts by loading a file containing scrambled word-answer pair separated. Sample of the file content is shown below. Once the pairs are loaded, it randomly picks a scrambled word and has the player guess it. The number of guesses is unlimited. When the user guesses the correct answer, it asks the user if he/she wants another scrambled word.

bta:bat
gstoh:ghost
entsrom:monster

Download scrambled.py (code featured below) and halloween.txt. The file scrambled.py already has the print_banner and the load_words functions. The function print_banner simply prints “scrambled” banner. The function load_words load the list of scrambled words-answer pairs from the file and return a tuple of two lists. The first list is the scrambled words and the second is the list of the answers. Your job is the complete the main function so that the game works as shown in the sample run.

Optional Challenge: The allowed number of guess is equal to the length of the word. Print hints such as based on the number of guess. If it’s the first guess, provides no hint. If it’s the second guess, provides the first letter of the answer. If it’s the third guess, provides the first and second letter of the correct answer. Also, make sure the same word is not select twice. Once all words have been used, the game should tell user that all words have been used and terminate.

Sample run:

__                               _      _            _
/ _\ ___ _ __ __ _ _ __ ___ | |__ | | ___   __| |
\ \ / __|| '__|/ _` || '_ ` _ \ | '_ \ | | / _ \ / _` |
_\ \| (__ | | | (_| || | | | | || |_) || || __/| (_| |
\__/ \___||_|   \__,_||_| |_| |_||_.__/ |_| \___| \__,_|                                                       

Scrambled word is: wbe
What is the word? bee
Wrong answer. Try again!
Scrambled word is: wbe
What is the word? web
You got it!
Another game? (Y/N):Y
Scrambled word is: meizob
What is the word? Zombie
You got it!
Another game? (Y/N):N
Bye!

Provided code (from scramble.py

def display_banner():
    print("""
__                               _      _            _
/ _\ ___ _ __ __ _ _ __ ___ | |__ | | ___   __| |
\ \ / __|| '__|/ _` || '_ ` _ \ | '_ \ | | / _ \ / _` |
_\ \| (__ | | | (_| || | | | | || |_) || || __/| (_| |
\__/ \___||_|   \__,_||_| |_| |_||_.__/ |_| \___| \__,_|                                                       

""")

def load_words(filename):
    #load file containing scrambled word-answer pairs.
    #scrambled word and answer are sparated by :

    scrambled_list = []
    answer_list = []

    with open(filename, 'r') as f:
        for line in f:
            (s,a) = line.strip().split(":")
            scrambled_list += [s]
            answer_list += [a]
    return (scrambled_list, answer_list)

                       

def main():
    display_banner()
    (scrambled_list, answer_list) = load_words('halloween.txt')
    #your code to make the game work.     

main()

Halloween.txt file.

bta:bat
gstoh:ghost
entsrom:monster
ihtcw:witch
meizob:zombie
enetskol:skeleton
rpamevi:vampire
wbe:web
isdepr:spider
umymm:mummy
rboom:broom
nhlwaeeol:Halloween
pkiumnp:pumpkin
kaoa jlern tcn:jack o lantern
tha:hat
claabck t:black cat
omno:moon
aurdclno:caluldron

In: Computer Science

Grettings, thanks in advance explain on this. Discuss 5 reasons why people still prefer NAT (Network...

Grettings,

thanks in advance

explain on this.

Discuss 5 reasons why people still prefer NAT (Network Address Translation) adoption rather than IPv6. ?

In: Computer Science

using java Consider the following LinkedList that is composed of 4 nodes containing 13, 7, 24,...

using java

Consider the following LinkedList that is composed of 4 nodes containing 13, 7, 24, 1. Assume that the Node.value is an int, and the reference to the first value is a Node called n. Write a method that computes the sum of all the values in the nodes of a linked list. For example, your method shall return the sum of all the nodes, in this example shall return 45

In: Computer Science

A full-time student pays $8,000 per semester. It has been announced that the tuition will increase...

A full-time student pays $8,000 per semester. It has been announced that the tuition will increase by 3 percent each year for the next three years. Write a program with a loop that displays the projected semester tuition amount for the next three years. Also, provide the option to the student to calculate the tuition for another three years using the same percent increase. Please remember, if the student decides to calculate the tuition for another three years the starting tuition will be calculated tuition value for the end of the 3-year period.

CALCULATE USING PYTHON PROGRAMMING LANGUAGE. PLEASE INCLUDE NOTES AS WELL.

In: Computer Science

1. Prove the language L is not regular, over the alphabet Σ = {a, b}. L...

1. Prove the language L is not regular, over the alphabet Σ = {a, b}. L = { aib2i : i > 0}

2) Prove the language M is not regular, over the alphabet Σ = {a, b}. M = { wwR : w is an element of Σ* i.e. w is any string, and wR means the string w written in reverse}. In other words, language M is even-length palindromes.

In: Computer Science

complete the program #include <cstdlib> #include <iostream> #include <iomanip> using namespace std; int main(int argc, char**...

complete the program

#include <cstdlib>
#include <iostream>
#include <iomanip>
using namespace std;
int main(int argc, char** argv)
{
int number, sum, count;
// Write a while loop that reads a number from the user and loop
// until the number is divisible by 7
cout << "What is the number? "; cin >> number; while ( ... ) { ... }
cout << number << " is divisible by 7!! << endl << endl;
// Write a for loop that counts down from 10 to 0
// Write a for for loop that adds up all the numbers from 1 to 512
// Write a while loop that reads numbers from the user. Each number must be
// between 0 and 100 (inclusive). The loop ends when the user enters -99.
// Print the average of all the numbers. sum = count = 0;
cout << "Enter number between 0 and 100: "; cin >> number;
while ( ... ) { if (number ... || number ... )
cout << "Not in the range. Skipping" << endl;
else { // count the number of entries and the total sum. ... }
cout << "Enter number between 0 and 100: "; cin >> number;
}
cout << "The average is:" << fixed << setprecision(2) << float(sum) / count << endl; return 0;

In: Computer Science

What four main types of actions involve databases What are the responsibilities of the DBA and...

What four main types of actions involve databases

What are the responsibilities of the DBA and the database designers?

What is the difference between controlled and uncontrolled redundancy? Illustrate with examples

In: Computer Science

Write a function in Python that solves the linear system ??=? using Gaussian Elimination, taking ?,?...

Write a function in Python that solves the linear system ??=? using Gaussian Elimination, taking ?,? as input. The function should have two phases: the elimination phase, and the back substitution phase. You can use numpy library.

In: Computer Science

Hotel Occupancy C++ Only Program Description Write a program that calculates the occupancy rate for a...

Hotel Occupancy

C++ Only

Program Description

Write a program that calculates the occupancy rate for a hotel. The program should read its data from a file named "hotel.dat". The first line of this file will be a single integer specifying the number of floors in the hotel. Each of the remaining (N) lines will have two integers; the number of rooms on that floor and the number of occupied rooms on that floor.

Your program should display the following:

  • How many rooms the hotel has,
  • How many rooms are occupied,
  • How many are unoccupied, and
  • The percentage of rooms that are occupied.

Notes

  1. Your program should be named hotel.cc.
  2. You can build this program initially to read from the keyboard, get that working, and then modify the program to read from the file.
  3. You will need to create the "hotel.dat" data file.

In: Computer Science

Write a JAVA application that asks elementary students a set of 10 math problems First ask...

Write a JAVA application that asks elementary students a set of 10 math problems

  1. First ask the user for a level and a problem type.
  2. You need to validate the level and problem type and loop until the user enters a correct one.
  3. There should be 3 levels. Level 1 operands would have values in the range of 0-9, level 2 operands would have values in the range of 0-99, and level 3 operands would have values in the range of 0-999.
  4. Each problem will consist of three randomly generated operands.
  5. There should be 4 problem types. Problem type 1 requires the student to find the sum of the three numbers, problem type 2 requires the user to find the integer average of the three numbers, problem type 3 requires the user to find the largest of the three numbers, and problem type 4 requires the user to find the smallest of the three numbers.
  6. The program should ask the user 10 questions.
  7. The program should randomly generate the numbers for each problem and display them to the user. Then the program should get the users answer and check that answer.
  8. The program should provide individual feedback for each problem. There should be 3 different positive and 3 different negative feedbacks chosen from for each problem.
  9. After the user finishes their 10 problems, display the number they got right and then query them if they want to play again. If they choose to play again, get a new level and problem type before asking 10 new problems.

In: Computer Science

In C++, Do some research to find the definitions of single recursion, binary recursion, and multiple...

In C++, Do some research to find the definitions of single recursion, binary recursion, and multiple recursion. What kinds of problems lend themselves to these different forms of recursion? Please be as detailed as possible. Thank you!

In: Computer Science

Java Using NetBean Calculate the interest for a bank account. Your program should use Scanner to...

Java Using NetBean

Calculate the interest for a bank account. Your program should use Scanner to collect account balance and interest rate (input 2.5 for 2.5%), and then output the interest should be paid.

interest = balance * interest_rate;

In: Computer Science