Questions
VB console .net framework I am missing something in my code below which will calculate factorials...

VB console .net framework

I am missing something in my code below which will calculate factorials individually into the file to be read by a sub using theis outdated language please Not Sreamwriter or Reader

fact*0, 2fact*0

Fact*1 , 2fact*1

Fact*2, 2fact*2

Fact*3, 2fact*3 (To 9)

Only the first 9 (0-8) but what I have doe calculates only the 9 factorial giving a single value

Public Function Calculate_fact(n_values As Integer) As Long
'calc local variables
Dim fact As Long = 1
Dim fact2n As Long
Dim i As Integer 'loop index
Dim fid1 As Integer = FreeFile()
FileOpen(fid1, "Newfile.dat", OpenMode.Output, OpenAccess.Write) ' open output file
'Calculaions
If n_values = 0 Then
Return fact
Else For i = 1 To n_values

Return fact = fact * i
Return fact2n = (2 * fact) * i
Next i
End If
  
MsgBox(fact, fact2n)
WriteLine(fid1, n_values, fact, fact2n)
FileClose(fid1)

End Function

In: Computer Science

Word to Digit Programming challenge description: Given a string representation of a set of numbers, print...

Word to Digit Programming challenge description:

Given a string representation of a set of numbers, print the digit representation of the numbers.

Input: Your program should read lines from standard input. Each line contains a list of word representations of numbers separated by a semicolon. There are up to 20 numbers in one line. The numbers are "zero" through "nine".

Output: Print the sequence of digits. Test 1 Input zero;two;five;seven;eight;four Expected Test 1 output 025784 Test 2 Input three;seven;eight;nine;two Expected Output 37892

PLEASE USE JAVA:

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

public class Main {
/**
* Iterate through each line of input.
*/
public static void main(String[] args) throws IOException {
InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
BufferedReader in = new BufferedReader(reader);
String line;
while ((line = in.readLine()) != null) {

///CODE GOES HERE


System.out.println(line);
}
}
}

In: Computer Science

Create a program with the Calculator.java code RUN the program with the invalid data arguments 1,...

  1. Create a program with the Calculator.java code
    1. RUN the program with the invalid data arguments 1, 3, 5x
    2. Take a screenshot of the output and describe what you think happened.
    3. MODIFY the code as in listing 14.2, NewCalculator.java , RUN it again with the same invalid input
    4. Take a screenshot of the new output and describe in your word document why you think the exception handling is a 'better' programming technique than just letting the program crash.

__________________________________________________________________________

The Calculator.java code

1: package com.java24hours;
2:
3: public class Calculator {
4: public static void main(String[] arguments) {
5: float sum = 0;
6: for (String argument : arguments) {
7: sum = sum + Float.parseFloat(argument);
8: }
9: System.out.println("Those numbers add up to " + sum);
10: }
11: }

__________________________________________________________________________

The NewCalculator.java code

1: package com.java24hours;
2:
3: public class NewCalculator {
4: public static void main(String[] arguments) {
5: float sum = 0;
6: for (String argument : arguments) {
7: try {
8: sum = sum + Float.parseFloat(argument);
9: } catch (NumberFormatException e) {
10: System.out.println(argument + " is not a number.");
11: }
12: }
13: System.out.println("Those numbers add up to " + sum);
14: }
15: }

In: Computer Science

Replace the lines marked with // *** with the appropriate C# code (may require more than...

Replace the lines marked with // *** with the appropriate C# code (may require more than one line of code to complete the missing parts).



// Program Description: This program uses two user defined methods to compute
//    the gross pay and net pay for an employee after entering the employee’s
//    last name, hours worked, hourly rate, and percentage of tax.

using System;
public static class Lab6
{
   public static void Main()
   {
      // declare variables
      int hrsWrked;
      double ratePay, taxRate, grossPay, netPay=0;
      string lastName;

     // enter the employee's last name
     Console.Write("Enter the last name of the employee => ");
     lastName = Console.ReadLine();

     // enter (and validate) the number of hours worked (positive number)
     do
     {
        Console.Write("Enter the number of hours worked (> 0) => ");
        hrsWrked = Convert.ToInt32(Console.ReadLine());
     } while (hrsWrked < 0);

     // enter (and validate) the hourly rate of pay (positive number)
     // *** Insert the code to enter and validate the ratePay

     // enter (and validate) the percentage of tax (between 0 and 1)
     // *** Insert the code to enter and validate taxRate

     // Call a method to calculate the gross pay (call by value)
     grossPay = CalculateGross(hrsWrked, ratePay);

     // Invoke a method to calculate the net pay (call by reference)
     CalculateNet(grossPay, taxRate , ref netPay);

     // print out the results
     Console.WriteLine("{0} worked {1} hours at {2:C} per hour", lastName,
                       hrsWrked, ratePay);
     // *** Insert the code to print out the Gross Pay and Net Pay
     Console.ReadLine();
  }

  // Method: CalculateGross
  // Parameters
  //      hours: integer storing the number of hours of work
  //      rate: double storing the hourly rate
  // Returns: double storing the computed gross pay
  public static double CalculateGross(int hours, double rate)
  {
     // *** Insert the contents of the CalculateGross Method
  }

  // Method: CalculateNet
  // Parameters
  //      grossP: double storing the grossPay
  //      tax: double storing tax percentage to be removed from gross pay
  //      netP: call by reference double storing the computed net pay
  // Returns: void
  public static void CalculateNet(double grossP, double tax, ref double netP)
  {
     // *** Insert the details of the CalculateNet Method
  }
}

In: Computer Science

Hi, I found this in the book balanced introduction to computer science,Javascript language, ⌈Log2(N)⌉ determine the...

Hi,

I found this in the book balanced introduction to computer science,Javascript language, ⌈Log2(N)⌉ determine the number of checks it takes for binary search to find an item. I also saw this ⌈Log2(N)⌉+1 to find the number of checks,

what is the difference between these 2, which one should I use?

In: Computer Science

Write a Java Program to place a pizza ordering program. It creates a pizza ordered to...

Write a Java Program to place a pizza ordering program. It creates a pizza ordered to the specifications that the user desires. It walks the user through ordering, giving the user choices, which the program then uses to decide how to make the pizza and how much the cost of the pizza will be. Note: Use dialog boxes for communicating with the user. Remember to use the JOptionPane class which is the graphical user interface (GUI) and Comments that are not read by the computer, they are for use by the programmer. They are to help a programmer document what the program does and how it accomplishes it. This is important when a programmer needs to modify code that is written by another person.

Task 1. Name the program, PizzaOrder.java

2. Write a welcome message that said, “Welcome to ___________________ Pizza.”

3. Ask the user to input his or her first name. “Enter your first name:”

4. A menu should display to the user: Pizza sizes (inches) Cost 10” $10.99 12” $12.99 14” $14.99 16” $16.99 What size pizza would you like? 10, 12, 14, or 16 (enter the number only):

5. After the user has inputted the number another print statement should ask “What type of crust do you want? (H)Hand-tossed, (T) Thin-crust, or (D) Deepdish (enter H, T, or D):”

6. After the user has inputted the type of crust another print statement asking All pizzas come with cheese. Additional toppings are $1.25 each, choose from: Pepperoni, Sausage, Onion, Mushroom Do you want Pepperoni? (Y/N):

7. After you inputted Yes, or No another question should pop up Do you want Sausage? (Y/N): then Do you want Onion? (Y/N): then Do you want Mushroom? (Y/N):

8. At the end, it should show a receipt depending on the input: Note: The sales tax is 8.875% (below is an example) Your order is as follows:

10-inch Pizza

Hand-tossed crust $ 10.99

Pepperoni $ 1.25

The subtotal cost of your order is: $ 12.24

The tax is: $ 1.09 ----------------

total is: $ 13.33

*Your order will be ready for pick up in 30 minutes*

In: Computer Science

Language C++ Ask the user to enter their weight (in pounds) and their height in inches....

Language C++

Ask the user to enter their weight (in pounds) and their height in inches. Calculate their Body Mass Index (BMI) and tell them whether they are underweight, overweight, or at optimal weight.

BMI formula: weight * 703 / (height * height)

Optimal weight is a BMI from 19 to 26. Lower is underweight, higher is overweight.

Prompts:

Enter your weight (in pounds): [possible user input: 144]

Enter your height (in inches): [posible user input: 73]

Possible Outputs:

Your BMI is 18.9964, which means you are underweight.

Your BMI is 29.2612, which means you are overweight.

Your BMI is 25.8704, which means you are at optimal weight.

Notes and Hints:

1) For simplicity, assume user entries will be in whole numbers. However, BMI must be calculated with decimals.

2) You must use an if/else if structure for this

In: Computer Science

Suppose we have an array as follow: var $fruits =new Array(“banana”, “strawberry”, “papaya”, “melon”); Write a...

Suppose we have an array as follow: var $fruits =new Array(“banana”, “strawberry”, “papaya”, “melon”); Write a PHP script which will display the list of fruits in the browser as below: • Fruit 1: banana • Fruit 2: strawberry • Fruit 3: papaya

In: Computer Science

You are volunteering for a local children's softball league. They asked you to create an app...

You are volunteering for a local children's softball league. They asked you to create an app or a Web application to help in their operations. You decide to create a database. The league consists of several teams. Players are assigned to teams at the start of the season. It also collects parents' contact information, and charges season and optional equipment rental fees. League volunteers include officials, referees, coaches, and first aid attendants. Parents also volunteer to help at individual practices and games. The teams meet for regular practices at several ballparks at public parts; practices are scheduled, and permits are obtained from the city. Regular season and playoff games are scheduled at some or all of these ballparks; results and player statistics are collected.

For the first draft of your system:

1) Identify business rules your design will capture.

2) Identify entities, keys, and constraints. Create an ER diagram (format and software package up to you). You can also design your database directly in terms of DB tables. (one possible tool: https://sqldbm.com/Home/ ).

3) Based on ER model, design a database (skip this step if your design is already in DB-specific terms). Suggest foreign key constraints and indexes.

4) Is your design in 3rd Normal Form. If so, explain. If it is not, revise your design until it is in 3NF.

5) Generate or write SQL DDL statements that create your database objects.

In: Computer Science

Language C++ Most people know that the average human body temperature is 98.6 Fahrenheit (F). However,...

Language C++

Most people know that the average human body temperature is 98.6 Fahrenheit (F). However, body temperatures can reach extreme levels, at which point the person will likely become unconscious (or worse). Those extremes are at or below 86 F and at or above 106 F.

Write a program that asks the user for a body temperature in Fahrenheit (decimals are ok). Check if that temperature is in the danger zone (for unconsciousness) or not and produce the relevant output shown below. Also check if the user entered a number greater than zero. If they didn't, display an error message and don't process the rest of this program.

If the entry was valid, convert the temperature from Fahrenheit to Celsius. and output it to the user.

F to C formula: (temp - 32) * 5 / 9

Prompts:

Enter a body temperature in Fahrenheit: [possible user input: 107]

Possible Outputs:

This person is likely unconscious and in danger
Temperature in Celsius is: 41.6667

This person is likely conscious
Temperature in Celsius is: 37

Invalid entry

Notes and Hints:

1) This exercise is testing your knowledge of Flags and Logical Operators. Use both!

2) Do not use constants for the numbers in the F to C formula. Write it as-is.

3) Hint: The order in which you do your decision/conditional statements makes all the difference

4) Remember: Do not let this program do any math if the user's entry is invalid!

In: Computer Science

There is already an existing class called Sizes, with an existing main method. Inside the Sizes...

There is already an existing class called Sizes, with an existing main method.

Inside the Sizes class, create a method called menu. The purpose of this method is to display the menu on the screen and allow the user to make a choice from the menu.

Do not change any of the existing code in the main method, and do not add code to the main method. Changing the main method in any way will give you an automatic grade of zero on this part of the assignment.

This method does not need to accept any parameters from the main method. Choices should be read into the menu method from the keyboard as a number 1, 2, 3 or 4. This method will need to contain a loop which will repeat the process of displaying the menu and getting an input value as long as the user does not enter a correct menu option. After a correct menu option has been entered, the method should return that choice back to the main method.

Note that this method is required to verify that the entered choice is correct, so the main method does not have to do that task.

The following is an example of what your MIGHT see on the screen when your menu method executes. The exact output depends on what values that the user types in while the program runs. The user's inputted values are shown below in italics. Note that your method must display the exact formatting shown here - including the spaces and blank lines.

In: Computer Science

How do you transform from first normal form to second normal form?

How do you transform from first normal form to second normal form?

In: Computer Science

Explain of how the implementation of a Python dictionary works in 8-10 sentences. In particular, how...

Explain of how the implementation of a Python dictionary works in 8-10 sentences. In particular, how are keys and values stored? What hash function is used? How are collisions resolved? How is the size/capacity of the dictionary maintained?

In: Computer Science

Language C++ Ask the user to enter the name of one primary color (red, blue, yellow)...

Language C++

Ask the user to enter the name of one primary color (red, blue, yellow) and a second primary color that is different from the first. Based on the user's entries, figure out what new color will be made when mixing those two colors. Use the following guide:

  • red and blue make purple
  • blue and yellow make green
  • yellow and red make orange

If the user enters anything that is outside one of the above combinations, return an error message.

Prompts:

Enter a primary color (red, blue, yellow): [possible user input: red]

Enter a different primary color (red, blue, yellow): [possible user input: blue]

Possible Outputs:

red and blue make purple

blue and yellow make green

yellow and red make orange

You entered invalid colors

Notes and Hints:

1) The program should work regardless of the color order. In other words, it shouldn't matter if the user enters red or blue first...the two colors make purple.

2) Regarding #1, this means that the first three outputs shown above may appear with the colors in a different order. Hint: Use variables in your output to make this easy!

3) If the user has any uppercase letters, it will not work. This is normal, as C++ is case sensitive. We will solve this problem in a future in-class lesson.

In: Computer Science

C programming. Write a program that prompts the user to enter a 6x6 array with 0...

C programming. Write a program that prompts the user to enter a 6x6 array with 0 and 1, displays the matrix, and checks if every row and every column have the even number of 1’s.

In: Computer Science