In: Computer Science
Write a program that prompts the user to enter three sets of five double numbers each. (You may assume the user responds correctly and doesn’t enter non-numeric data.)
The program should accomplish all of the following:
a. Store the information in a 3×5 array.
b. Compute the average of each set of five values.
c. Compute the average of all the values.
d. Determine the largest value of the 15 values.
e. Report the results.
Each major task should be handled by a separate function using the traditional C approach to handling arrays.
Accomplish task “b” by using a function that computes and returns the average of a one-dimensional array; use a loop to call this function three times.
The other tasks should take the entire array as an argument, and the functions performing tasks “c” and “d” should return the answer to the calling program.
Must be done in C for DEV C++
In: Computer Science
This exercise will test your ability to use the basic instance methods of String. The exercise is to create a program that compares two Strings ignoring the case and returns the offset between the first two distinct characters in the two Strings from left to right.
All the input strings have five characters.
For this exercise, compareToIgnoreCase() and compareTo() methods are not allowed.
Example 1, "London" and "Lately" will return the offset between 'o' and 'a', which is 14
Example 2, "London" and "lately" will return the offset between 'o' and 'a', which is 14
Example 3, "LONDON" and "lately" will return the offset between 'o' and 'a', which is 14
Example 4, "LONDON" and "Loathe" will return the offset between 'n' and 'a', which is 13
Example 4, "LONDON" and "london" will return 0
The class name should be: Lab14_CustomizedStringComparison
In: Computer Science
What kind of problems attributes make in entropy-based decision trees. How can we solve them?
In: Computer Science
by python
Question #1 Consider a 5-point quiz system. A score can be any number between 0 and 5. Using mathematical interval notation, the score is in the interval [0,5][0,5]. The interval notation (4,5](4,5] means that number 4 is not in the interval. Hence the numbers included in this interval are all real values ?x such that 4<?≤54
The score is graded according to the following scale:
Score | Grade |
---|---|
(4, 5] | A |
(3, 4] | B |
(2, 3] | C |
(1, 2] | D |
[0, 1] | F |
Write a program that reads a quiz score and then prints out the corresponding grade.
Note that your program should
The following are two sample runs of the program:
Sample Run 1:
Please enter score: -1
Invalid score. Try again.
Please enter score: 5.5
Invalid score. Try again.
Please enter score: 3.5
Your grade is B
In: Computer Science
For this project, you will create a program in C that will test the user’s proficiency at solving different types of math problems. The program will be menu driven. The user will select either addition, subtraction, multiplication or division problems. The program will then display a problem, prompt the user for an answer and then check the answer displaying an appropriate message to the user whether their answer was correct or incorrect. The user will be allowed 3 tries at each problem. The program will also keep statistics on how many problems were answered correctly.
This week you will add functions to allow the user to select problems of varying degrees of difficulty and also keep statistics on number of correct answers vs. total number of problems attempted.
So now let’s add the code for the remaining functions:
We’ll start by inserting code to ask the user if they want to see problems that are easy, medium or difficult. We’ll do this by prompting them to enter ‘e’ for easy, ‘m’ for medium or ‘d’ for difficult and we’ll do this right after they have selected the type of problems they want. We will also add a validation loop that will check to see if they entered a correct response (e,m, or d).
Easy – problems using numbers 0 thru 10
Medium – problems 11 thru 100
Difficult – problems 100 – 1000
Here’s some code to get you started on the “difficulty level.”
if( difficultyLevel == 'E')
{
num1=rand()%10+1;
num2=rand()%10+1;
}
else
if (difficultyLevel == 'M')
{num1=rand()%100+1;
num2=rand()%100+1;
}
else
{ num1=rand()%1000+1;
num2=rand()%1000+1;}
Use an “if” statement to check the difficulty and generate the random numbers.
Statistics:
Create two variables ttlProblems and correctAnswers. Every time the user answers a problem add 1 to ttlProblems and every correct answer add 1 to correctAnswers. We’ll display the total number of problems and correct answers as well as the percent correct after the user has selected the exit option on the main menu.
Then, alter the code to allow for floating point numbers. This requires formatting the output.
In: Computer Science
JAVA :
Many games are played with dice, known as a die in the singular. A die is a six-sided cube whose sides are labeled with one to six dots. The side that faces up indicates a die's face value.
Design and implement a Java class Die that represents one 6-sided die. You should be able to roll the die and discover its upper face. Thus, give the class the method int roll, which returns a random integer ranging from 1 to 6, and the method int getFaceValue, which returns the current face value of the die (last value rolled). Note a call to roll will return the same value as a subsequent call to getFaceValue.
Often, games depend on the roll of two dice. Using your class Die, design and implement a Java class TwoDice with an aggregation ("has-a") relationship to the Die class. An object of TwoDice represents two six-sided dice that are rolled together. Include at least the following TwoDice methods: int rollDice, int getFaceValue1, int getFaceValue2, int getValueOfDice (returns the sum of the two dice values), boolean isMatchingPair, boolean isSnakeEyes, andString toString.
Demonstrate your Die and TwoDice classes using the following test client:
public class Main
{
public static void main(String[] args)
{
Die dieOne = new Die();
Die dieTwo = new Die();
Die dieThree = new
Die();
System.out.println("Demonstrating the Die class:");
System.out.println("Rolling
dieOne: " + dieOne.roll());
System.out.println("Rolling
dieTwo: " + dieTwo.roll());
System.out.println("Rolling
dieThree: " + dieThree.roll());
TwoDice dice = new
TwoDice();
System.out.println("Demonstrating the TwoDice class: ");
System.out.println("Rolling
dice: [" + dice.getFaceValue1()
+ ", " + dice.getFaceValue2() + "]");
dice.rollDice();
System.out.println("Rolling
dice: [" + dice.getFaceValue1()
+ ", " + dice.getFaceValue2() + "]");
dice.rollDice();
System.out.println("Rolling
dice: [" + dice.getFaceValue1()
+ ", " + dice.getFaceValue2() + "]");
}
}
In: Computer Science
In: Computer Science
c# language
Write a program that takes in a number from the user. Then it prints a statement telling the user if the number is even or odd. If the number is odd, it counts down from the number to 0 and prints the countdown on the screen, each number on a new line. If the number is even, it counts down from the number to 0, only even numbers. For example, if the user enters 5, the output will look like this:
The number you entered is odd.
5
4
3
2
1
0
If the user enters 6, the output will look like this:
The number you entered is even.
6
4
2
0
Submit your .c file. Also submit a screen shot of the terminal with the output displayed.
In: Computer Science
In: Computer Science
(Write in PythonUse a for statement to print 10 random numbers between 25 and 35, inclusive.
(Write in Python)in python The Pythagorean Theorem tells us that the length of the hypotenuse of a right triangle is related to the lengths of the other two sides. Look through the math module and see if you can find a function that will compute this relationship for you. Once you find it, write a short program to try it out.
(Write in PythonSearch on the internet for a way to calculate an approximation for pi. There are many that use simple arithmetic. Write a program to compute the approximation and then print that value as well as the value of math.pi from the math module.
In: Computer Science
In: Computer Science
Python
#Note: use print() to add spaces between items and when needed
in the receipt
#(e.g. between user entries and between the entries and the
receipt)
#1 Ask the user for a number using the prompt: NUMBER?
# Convert the user entered number to an integer
# Calculate the square of the number and display the result on
screen with the following text before it: Your number squared
is
#2 Ask the user for a first number using the prompt: first
number?
# Ask the user for a second number using the prompt: second
number?
# Convert the two numbers to integers
# Multiply the first number by the second number and display the
result on screen with the following text before it: Result:
"""
#3 Develop a simple food receipt
a. Ask the user for inputs about two food items using the following
prompts in turn. Do not forget to assign each user
entry to a unique variable name:
Item1 name?
Item1 price?
Item1 quantity?
Item2 name?
Item2 price?
Item2 quantity?
b. Convert the price and quantity variables to integers
c. Calculate the total cost for the order by calculating each
item's total price by
multiplying price and quantity for each item and then adding up the
total prices for the two items
d. Display the results using the format:
RECEIPT
You ordered: [item1 name] and [item2 name]
Total cost: $ [total price for both items calculated in 3c
above]
"""
#Start your code below
Enhance your simple food receipt
a. Ask the user for inputs about two food items using the following
prompts in turn. Do not forget to assign each user
entry to a unique variable name:
First item name?
First item price?
First item quantity?
Second item name?
Second item price?
Second item quantity?
Third item name?
Third item price?
Third item quantity?
b. Convert the price and quantity variables to integers
c. Calculate the total cost for the order by calculating each
item's total price by
multiplying price and quantity for each item and then adding up the
total prices for the three items
d. Calculate the total cost plus tax for the order by multiplying
the total cose calculated in c by the tax rate of .09
then adding the tax to the total cost
e. Display the results using the format:
RECEIPT
You ordered: [First item name] [Second item name] [third item
name]
Total cost: $ [total price for all items calculated in 3c
above]
Total cost plus tax: $ {total cost plus tax calculated in 3d
above}
"""
#Start your code below
In: Computer Science
For each case below, graphically represent entities and relationships between entities. Include primary keys, foreign keys where appropriate. For each entity add a couple of attributes (fields) and then provide a brief statement explaining why each entity (table) is in 3NF.
An online retailer of coffee beans maintains a long list of unique coffee flavors. The company purchases beans from a number of suppliers; however, each specific flavor of coffee is purchased from only a single supplier. Many of the customers are repeat purchasers and typically order at least five flavors of beans in each order.
In: Computer Science
In Assembly Code
write an assembler code (Fibonacci.s) and show results
The Fibonacci Sequence is a series of integers. The first two numbers in the sequence are both 1; after that, each number is the sum of the preceding two numbers.
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...
For example, 1+1=2, 1+2=3, 2+3=5, 3+5=8, etc.
The nth Fibonacci number is the nth number in this sequence, so for example fibonacci(1)=1, fibonacci(2)=1, fibonacci(3)=2, fibonacci(4)=3, etc. Do not use zero-based counting; fibonacci(4)is 3, not 5.
Your assignment is to write an assembler code (Fibonacci.s) that asks the user for the nth term in the Fibonacci sequence. Your program should then calculate the nth Fibonacci number and print it out.
For example, you program should produce the following outputs:
Enter Fibonacci term: 6
The 6th Fibonacci number is 8
In: Computer Science