Questions
(java)Fix the code in this program. Fix lines, add lines… Comment each line that you fixed...

(java)Fix the code in this program. Fix lines, add lines…

Comment each line that you fixed … what you did to fix it.

import java.util.Scanner;
public static void main(String[] args)
{
// This program Converts grade Points into a Letter grade.
int gradePoints == 00; // Declare variable and assign initial value
System.out.printl("Enter Grade Points: ";
//Input gradePoints;
if ( gradePoints >= -42 )
{ System.out.println("Grade = A"); }
// if true, then ends here, if false drop to next line
else if ( gradePoints =< 80 ) { System.out.println("Grade = B"); }
//if true, then ends here, if false drop to next line
else if ( gradePoints >= 70 ) { System.out.println("Grade = C"); }
//if true, then ends here, if false drop to next line
else if ( gradePoints >= 60 ) { System.out.println("Grade = D"); }
// if true, then ends here, if false drop to next line
else { System.out.println("Grade = A"; } // done.
}

In: Computer Science

PLEASE PROVIDE COMMENTS ON STEPS IMPORTANT NOTE: The library string functions cant be used. You must...

PLEASE PROVIDE COMMENTS ON STEPS

IMPORTANT NOTE:

The library string functions cant be used. You must use pointers and the switch statement to execute this program. Assume that the vowels are a, e, i, o, u. The modification has to be done in the original char array without creating a new array.

Write a C++ program that modifies a string (null terminated) as follows:

Consonants are positioned at the beginning of the string and vowels are moved to the end of the string.

Example :

Original string : washer

New string : wshrae

In: Computer Science

Write a program that asks the user to enter a bunch of words until they type...

Write a program that asks the user to enter a bunch of words until they type the word “quit”. Count how many words had 5 letters or more.

Sample program

Enter a word: nothing

Enter a word: stop

Enter a word: word

Enter a word: program

Enter a word: supercalifragilisticexpialidocious

Enter a word: quit

You entered 3 words that were longer than 5 letters.

In: Computer Science

(java))Write a “Temperature Conversion” program. Declare choice, tempIn, tempOut variables Prompt the user with the messages...

(java))Write a “Temperature Conversion” program.

Declare choice, tempIn, tempOut variables

Prompt the user with the messages to choose: 1) Centigrade to Fahrenheit, 2) Fahrenheit to centigrade.

Prompt the user for temperature value (tempIn) to convert.

Calculate new tempOut. The calculation of the new tempOUT depends on choice 1 or 2 above.\

( Lookup up the C to F formula online, loop up the F to C formula online )

Print out the the F and the C temps.

Be sure to use the C and F temperature notation ASCII symbol.

In: Computer Science

how can i convert this to work in visual basic ? what are the formulas for...

how can i convert this to work in visual basic ? what are the formulas for that?

You must create a Windows Forms application as the Conversion project including a picture of money on your form.  Create a textbox for the user to entry a dollar amount. Determine the number of quarters, dimes, nickels, and pennies using label controls to display the results.  In your calculation, you should use constant variables.


ex)

Enter dollar amount for conversion of 4.69

Number of quarters = 18
Number of dimes = 1
Number of nickels = 1
Number of pennies = 4

In: Computer Science

Print out a table of powers. Use a for loop that goes from 101 to 112...

Print out a table of powers. Use a for loop that goes from 101 to 112 inclusive. Print out r, r squared, r cubed, square root of r, and cube root of r. Use two decimal places for the roots, and zero decimal places for the squares and cubes, and 2 decimal places for the averages. Use commas in numbers 1000 and above. After the loop, print out the average of the r squared and r cubed. Use columns for your data. Print column headings above your loop.Also print the data to a file.

In C++

In: Computer Science

#include <iostream> #include <string> #include <array> #include <vector> using namespace std; void f(int x, int &y);...

#include <iostream>
#include <string>
#include <array>
#include <vector>
using namespace std;
void f(int x, int &y);
int main(){
  char s1[] = "zoey";
  char s2[] = "zoey";
  string s3 = s1;
  string s4 = s2;
  cout << "1.  sizeof(s1) = " << sizeof(s1) << endl;
  if(s1 == s2) cout << "2.  s1 == s2 is true" << endl;
  else cout << "2.  s1 == s2 is false" << endl;
  if(s3 == s4) cout << "3.  s3 == s4 is true" << endl;
  else cout << "3.  s3 == s4 is false" << endl;
  array<double, 5> d = {7.5, 2.8, 9.5, 88.7, 1.7};
  vector<int> v;
  for(size_t i = 0; i < 4; i++){
    v.push_back((unsigned long) &d[i+1] - (unsigned long) &d[i]);
  }
  cout << "4.  The values stored in v are ";
  for(int value : v){
    cout << value << " ";
  }

cout << endl;

char * p1 = &s4[0];
*p1 = 'j';
*(&s4[3]) = 's';
cout<<"5. s4="<<s4<<endl;

s4 = s1;
string s5("zoey\0 is awesome"); cout<<"6. s5="<<s5<<endl;

int q[5];
int * p2 = q;
for(int i = 1; i < 6; i++) *(p2 + i - 1) = i * 5;
f(*(q + 1), *(q + 2));
cout << "7. What is the value of (q[1] + q[2])?" << endl;
cout << "8. What is the value of q?" << endl;
cout << "9. p2 = " << (unsigned long) p2 << ", q = " << (unsigned long) q << endl; cout<<"10.p2="<<p2<<",q="<<q <<endl;

2

return 0; }

void f(int x, int &y){
  x = -1;

y = -2; }

An output for the C++ (version 14) program above executed on nike.

1. sizeof(s1) = 5
2. s1 == s2 is false
3. s3 == s4 is true
4. Thevaluesstoredinvare8888
5. s4 = joes
6. s5 = zoey
7. What is the value of (q[1] + q[2])?
8. What is the value of q?
9. p2 = 140726181901504, q = 140726181901504 10. p2 = 0x7ffd5e1534c0, q = 0x7ffd5e1534c0

Create a file called lab04Answers.txt on nike, and answer the following 10 questions based on the C++ program and its output above.

  1. In the output for 1 above, why is sizeof(s1) = 5 even though s1 contains only four letters? What is character is being stored in the fifth byte of s1?

  2. In the output for 2 above, why does s1 == s2 result in false when both s1 and s2 contain the same character sequence? What values are being compared in s1 == s2 to yield a result of false?

  3. In the output for 3 above, why does s3 == s4 result in true? What values are being compared in s3 == s4? What types of strings are s3 and s4, and how are they different than the types of string used for s1 and s2?

  4. In the output for 4 above, explain why the values stored in v are all 8? Explain your answers in terms of how the memory addresses are being stored for d. Assume the starting address of d is 500, then what are the memory addresses for d[0], d[1], d[2], d[3], and d[4]?

  5. Why is joes in the output for 5 above? Explain how the first character in s4 was changed to ’j’. Explain how the last character in s4 was changed to ’s’.

  6. Why did the output for 6 above print s5 = zoey instead of s5 = zoey is awesome?

  7. As asked in the output for 7 above, what is the value of (q[1] + q[2])? Is it correct syntax to use *(q[1] + q[2]) to compute the value of (q[1] + q[1])? Explain why this syntax is correct or why it isn’t correct.

  8. As asked in the output for 8 above, what is the value of q? Explain what this value represents in terms of what is going on in the program’s memory at runtime.

  9. Consider the output for 9 and 10 above. Why do these memory addresses typically change each time this program is run on nike?

  10. Consider the output for 9 and 10 above. The memory addresses that are being display to standard output for 9 above are using which number system: binary, octal, base-10, or hexadecimal? The memory addresses that are being display to standard output for 10 above are using which number system: binary, octal, base-10, or hexadecimal?

In: Computer Science

Project 6-1: Email Creator C++ code Create a program that reads a file and creates a...

Project 6-1: Email Creator

C++ code

Create a program that reads a file and creates a series of emails.

Console

Email Creator

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

To:      [email protected]

From:    [email protected]

Subject: Deals!

Hi James,

We've got some great deals for you. Check our website!

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

To:      [email protected]

From:    [email protected]

Subject: Deals!

Hi Josephine,

We've got some great deals for you. Check our website!

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

To:      [email protected]

From:    [email protected]

Subject: Deals!

Hi Art,

We've got some great deals for you. Check our website!

Specifications

  • Your instructor should supply you with a file named email_list.txt that contains a list of email addresses in this format:

james\tbutler\[email protected]

josephine\tdarakjy\[email protected]

art\tvenere\[email protected]

  • Your instructor should supply you with a file named email_template.txt that provides a template for a mass email in a file like this:

To:      {email}
From:    [email protected]
Subject: Deals!

Hi {first_name},

We've got some great deals for you. Check our website!

  • When the program starts, it should read the email addresses and first names from the file, merge them into the mass email template, and display the results on the console.
  • All email addresses should be converted to lowercase.
  • All first names should be converted to title case.
  • If you add names to the list of email addresses, the program should create more emails.
  • If you modify the template, the program should change the content of the email that’s created.

-------------------

Text files

(email_template.txt)

To: {email}
From: [email protected]
Subject: Deals!

Hi {first_name},

We've got some great deals for you. Check our website!

email_list.txt

james   butler   [email protected]
josephine   darakjy   [email protected]
art   venere   [email protected]

In: Computer Science

/** * Loads a list of items from the given file. Each line is in the...

/**
* Loads a list of items from the given file. Each line is in the format
* <item type>~<item data>. The createFromString() methods in the item
* classes will be used to parse the item data.
* @param filename the filename
* @return the list of items
* @throws IOException if the file can't be opened
*/
public static List<Item> loadItems(String filename) throws IOException {
List<Item> items = new ArrayList<>();
Scanner inPut = new Scanner(new FileReader(filename));
       while(inPut.hasNextLine()) {
           String line = inPut.nextLine();
           String [] tokens = line.split(":");
           String type = tokens[0];
           String data = tokens[1];
           items.add(type,data);
       }
return items;
}
}

can you please check this line " items.add(type,data);" . I am having problem with it

In: Computer Science

USING MATLAB: Using the data from table below fit a fourth-order polynomial to the data, but...

USING MATLAB:

Using the data from table below fit a fourth-order polynomial to the data, but use a label for the year starting at 1 instead of 1872. Plot the data and the fourth-order polynomial estimate you found, with appropriate labels. What values of coefficients did your program find? What is the LMS loss function value for your model on the data?

Year Built SalePrice
1885 122500
1890 240000
1900 150000
1910 125500
1912 159900
1915 149500
1920 100000
1921 140000
1922 140750
1923 109500
1925 87000
1928 105900
1929 130000
1930 138400
1936 123900
1938 119000
1939 134000
1940 119000
1940 244400
1942 132000
1945 80000
1948 129000
1950 128500
1951 141000
1957 149700
1958 172000
1959 128950
1960 215000
1961 105000
1962 84900
1963 143000
1964 180500
1966 142250
1967 178900
1968 193000
1970 149000
1971 149900
1972 197500
1974 170000
1975 120000
1976 130500
1977 190000
1978 206000
1980 155000
1985 212000
1988 164000
1990 171500
1992 191500
1993 175900
1994 325000
1995 236500
1996 260400
1997 189900
1998 221000
1999 333168
2000 216000
2001 222500
2002 320000
2003 538000
2004 192000
2005 220000
2006 205000
2007 306000
2008 262500
2009 376162
2010 394432

In: Computer Science

Programming Activity 7 - Guidance ================================= This assignment uses a built-in Python dictionary. It does not...

Programming Activity 7 - Guidance =================================

This assignment uses a built-in Python dictionary. It does not use a dictionary implementation from the textbook collections framework. It does not require any imports/files from the textbook collections framework. This week's "examplePythonDictionary.py" example uses a built-in Python dictionary. Note that the mode() function begins by creating an empty Python dictionary. You must use this dictionary in the following parts.

Part 1 ------ In this part you will add entries to the dictionary. Use a "for" loop to iterate through the values in the data list. For each value, use it as a dictionary key to see if it is already in the dictionary. If it is already in the dictionary, add one to that dictionary entries value. Each dictionary value contains the number of times that value occurs in the data. You reference the current value for a key via dictionary[key]. If it is not in the dictionary, add it by assigning an entry for it with a value of 1.

Part 2 ------ Python has a built-in max() function that finds the maximum in any iterable object. Use max() on the list of dictionary values to obtain the maximum number of times a value occurs. Assign this to a variable called maxTimes. You will make use of maxTimes in part 3.

Part 3 ------ Note that this part begins by creating an empty modes list. Use a "for" loop to loop through the dictionary keys. The default "for" iterator for a Python dictionary iterates through its keys. For each key, see if its associated dictionary value is equal to maxTimes. If it is equal, append that key to the modes list.

Part 4 ------ If no item in the data set is repeated, then your modes list at this point will be the same as your starting data list. However, this case actually should mean there is no mode. Actually, every item is a mode with a frequency of 1. But, we want to return an empty modes list for this case. If the modes list and the data list have the same length, reset modes to an empty list. Note that modes is already being returned at the end of the function.

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

useDictionary.py

# This program uses a Python dictionary to find the mode(s) of a data set.

# The mode of a data set is its most frequently occurring value.
# A data set may have more than one mode.
# Examples:
# mode of [1,2,3,4,5,6,7] is none
# mode of [1,2,3,4,5,6,7,7] is 7
# modes of [1,2,2,2,3,3,4,5,6,7,7,7] are 2 and 7

# Replace any "<your code>" comments with your own code statement(s)
# to accomplish the specified task.
# Do not change any other code.

# This function returns a list containing the mode or modes of the data set.
# Input:
# data - a list of data values.
# Output:
# returns a list with the value or values that are the mode of data.
# If there is no mode, the returned list is empty.
def mode(data):
dictionary = {}

# Part 1:
# Update dictionary so that each dictionary key is a value in data and
# each dictionary value is the correspinding number of times that value occurs:
# <your code>

# Part 2:
# Find the maximum of the dictionary values:
# <your code>

# Part 3:
# Create a list of the keys that have the maximum value:
modes = []
# <your code>

# Part 4:
# If no item occurs more than the others, then there is no mode:
# <your code>

return modes

data1 = [1,2,3,4,5,6,7]
print(data1)
print("mode:", mode(data1))
print()

data2 = [1,2,3,4,5,6,7,7]
print(data2)
print("mode:", mode(data2))
print()

data3 = [1,2,2,2,3,3,4,5,6,7,7,7]
print(data3)
print("mode:", mode(data3))
print()

data4 = ["blue", "red", "green", "blue", "orange", "yellow", "green"]
print(data4)
print("mode:", mode(data4))
print()

In: Computer Science

A chain of four matrices A1, A2, A3 and A4, with order 3 X 4, 4...

A chain of four matrices A1, A2, A3 and A4, with order 3 X 4, 4 X 2, 2 X 8 and 8 X 7 respectively. Deduce m[1, 4] to find best possible minimum number of multiplication

In: Computer Science

Room.java: public class Room { // fields private String roomNumber; private String buildingName; private int capacity;...

Room.java:

public class Room
{
// fields
private String roomNumber;
private String buildingName;
private int capacity;

public Room()
{
this.capacity = 0;
}
/**
* Constructor for objects of class Room
*
* @param rN the room number
* @param bN the building name
* @param c the room capacity
*/
public Room(String rN, String bN, int c)
{
setRoomNumber(rN);
setBuildingName(bN);
setCapacity(c);
}
  
/**
* Mutator method (setter) for room number.
*
* @param rN a new room number
*/
public void setRoomNumber(String rN)
{
this.roomNumber = rN;
}
  
/**
* Mutator method (setter) for building name.
*
* @param bN a new building name
*/
public void setBuildingName(String bN)
{
this.buildingName = bN;
}
  
/**
* Mutator method (setter) for capacity.
*
* @param c a new capacity
*/
public void setCapacity(int c)
{
this.capacity = c;
}
  
/**
* Accessor method (getter) for room number.
*
* @return the room number
*/
public String getRoomNumber()
{
return this.roomNumber;
}
  
/**
* Accessor method (getter) for building name.
*
* @return the building name
*/
public String getBuildingName()
{
return this.buildingName;
}
  
/**
* Accessor method (getter) for capacity.
*
* @return the capacity
*/
public int getCapacity()
{
return this.capacity;
}
}

Put the ideas into practice by extending the original Room class to create an AcademicRoom.java class.

  1. The AcademicRoom.java should store information about the building name, room number, capacity, academic department associated with the room (CPSC, MATH, BUAD, ...) and also whether or not the room contains a projector. Make sure to utilize inheritance (only add new fields to AcademicRoom).
  2. Include a constructor for the AcademicRoom class that takes advantage of the reserved word super. Also include appropriate getter/setter methods for the AcademicRoom.
  3. Add James Farmer B6 to your list as well as two or three other classrooms of your choosing.
  4. Implement a test program (TestAcademicRoom.java) with a main() that creates an ArrayList of AcademicRooms. After the list is created, allow the user to: (1) add another room to the list, and (2) search for rooms. The program should not add the room if it already exists in the list. The user should search by inputting a building name and optionally a room number. If a room number is not provided, the program should print all rooms in that building. If matches are found in the list, print all the data members associated with the AcademicRoom(s).

In: Computer Science

I need to create a program that will simulate an ATM. The program has to be...

I need to create a program that will simulate an ATM. The program has to be written in JAVA that uses JOptionaPane to pop up the messages. It will need to simulate to get

** balance

**withdraw

**Deposit

**exit the atm

** need to have a method that shows a receipt of everything that was done during the transaction

In: Computer Science

Create a program wages.py that assumes people are paid double time for hours over 60. They...

Create a program wages.py that assumes people are paid double time for hours over 60. They get paid for at most 20 hours overtime at 1.5 times the normal rate.

For example, a person working 65 hours with a regular wage of $10 per hour would work at $10 per hour for 40 hours, at 1.5 * $10 for 20 hours of overtime, and 2 * $10 for 5 hours of double time, for a total of

10*40 + 1.5*10*20 + 2*10*5 = $800.

The number of hours should be generated randomly between 35 and 75.

If the number of working hours is less than 40, display message “The salary cannot be generated” with sound of system bell as a warning.

In: Computer Science