Java Coding Program.
In this assignment, you will write a program that analyzes Phoenix area 2018 rainfall data. Inside the main() method, first you will get the rainfall data for each of the 12 months in 2018 from the user and stores them in a double array. Next, you will need to design the following four value-returning methods that compute and return to main() the totalRainfall, averageRainfall, driestMonth, and wettestMonth. The last two methods return the index (or number) of the month with the lowest and highest rainfall amounts, not the amount of rain that fell those months. Notice that this month index (or number) can be used to obtain the amount of rain that fell those months.
I need help with driestMonth and wettestMonth. Wettest month is not giving me the correct output.
This is how it should read when it prints out on screen. Example : "The least rain fell in May with 0.35 inches."
This is what I have so far.
----------------------------------------------------------------------------
import java.util.Scanner;
import java.text.DecimalFormat;
public class Assignment12
{
public static void main(String[] args)
{
// variables
final int numMonths = 12;
double[] rainArray = new double[numMonths];
String[] month = {"Januray", "February", "March", "April",
"May",
"June", "July", "August", "September",
"October", "November", "December"};
Scanner scan = new Scanner(System.in);
DecimalFormat fmt = new DecimalFormat("0.00");
// get user input for rainfall each month
for(int i=0; i < numMonths; i++)
{
System.out.print("\nEnter " + month[i] + " rainfall amount:
");
rainArray[i] = scan.nextDouble();
}
System.out.print("\n==== 2018 Rain Report for Phoenix, AZ
====");
System.out.print("\nTotal rainfal: " +
fmt.format(getTotal(rainArray)));
System.out.print("\nAverage monthly rainfall: " +
fmt.format(getAverage(rainArray)));
System.out.print("\nThe least rain feel in " +
getWettestMonth(rainArray));
System.out.print("\nThe most rain fell in ");
}
public static double getTotal(double[] rainArray)
{
double total = 0;
final int numMonths = 12;
for(int i=0; i < numMonths; i++)
{
total = total + rainArray[i];
}
return total;
}
public static double getAverage(double[] rainArray)
{
double total = 0;
double average = 0;
final int numMonths = 12;
for(int i=0; i < numMonths; i++)
{
total = total + rainArray[i];
}
average = total / numMonths;
return average;
}
public static int getWettestMonth(double[] rainArray)
{
int mostRainIndex = 0;
final int numMonths = 12;
for(int i=0; i < numMonths; i++)
{
if(rainArray[i] > rainArray[mostRainIndex])
{
mostRainIndex = i;
}
}
return mostRainIndex;
}
public static int getDriestMonth(double[] rainArray)
{
//code
}
}
In: Computer Science
For this assignment, we will learn to use Python's built in set type. It's a great collection class that allows you to get intersections, unions, differences, etc between different sets of values or objects.
1. Create a function named common_letters(strings) that returns the intersection of letters among a list of strings. The parameter is a list of strings.
For example, you can find the common letter in the domains/words statistics, computer science, and biology. You might easily see it, but you need to write Python code to compute the answer. In order to pass the tests you must use the set api.
In: Computer Science
A certain symmetric encrption system El uses the following secret key (KI) for confidential communication between A and B FEA01FAA3459012D (hex) A decides to deliver this secret key (K1) to B by transmitting it over the same insecure channel using a second encryption scheme E2 a- What method of encryption would you suggest for E2? b- Based on your suggestion, what would be the size in bits of the key (K2) used in encryption system E2? c- If a system of computers has the ability to try 64 keys every 100 microseconds in an effort to decipher the message encrypted by E1 by brute force, how long (on average) would it take to break the code? d- Is El computationally secure?
In: Computer Science
System Analysis project 4: can you answer the 4
questions at the task section, thank you.
Personal Trainer, Inc. owns and operates fitness centers in a dozen
Midwestern cities. The centers have done well, and the company is
planning an international expansion by opening a new “supercenter”
in the Toronto area. Personal Trainer’s president, Cassia Umi,
hired an IT consultant, Susan Park, to help develop an information
system for the new facility. During the project, Susan will work
closely with Gray Lewis, who will manage the new operation.
Background During requirements modeling for the new system, Susan
Park met with fitness center managers at several Personal Trainer
locations. She conducted a series of interviews, reviewed company
records, observed business operations, analyzed the BumbleBee
accounting software, and studied a sample of sales and billing
transactions. Susan’s objective was to develop a list of system
requirements for the proposed system.
Fact-Finding Summary
• A typical center has 300–500 members, with two membership levels: full and limited. Full members have access to all activities. Limited members are restricted to activities they have selected, but they can participate in other activities by paying a usage fee. All members have charge privileges. Charges for merchandise and services are recorded on a charge slip, which is signed by the member. • At the end of each day, cash sales and charges are entered into the BumbleBee accounting software, which runs on a computer workstation at each location. Daily cash receipts are deposited in a local bank and credited to the corporate Personal Trainer account. The BumbleBee program produces a daily activity report with a listing of all sales transactions. • At the end of the month, the local manager uses BumbleBee to transmit an accounts receivable summary to the Personal Trainer headquarters in Chicago, where member statements are prepared and mailed. Members mail their payments to the Personal Trainer headquarters, where the payment is applied to the member account. • The BumbleBee program stores basic member information, but does not include information about member preferences, activities, and history. • Currently, the BumbleBee program produces one local report (the daily activity report) and three reports that are prepared at the headquarters location: a monthly member sales report, an exception report for inactive members and late payers, and a quarterly profitand-loss report that shows a breakdown of revenue and costs for each separate activity. During the interviews, Susan received a number of “wish list” comments from managers and staff members. For example, managers want more analytical features so they can spot trends and launch special promotions and temporary discounts. Managers also want better information about the profitability of specific business activities at their centers, instead of bottom-line totals. Several managers want to offer computerized activity and wellness logs, fitness coaching for seniors, and various social networking options, including e-mail communications, fitness blogs, Facebook, and Twitter posts. Staff members want better ways to handle information about part-time instructors and trainers, and several people suggested using scannable ID cards to capture data
Tasks
1. Draw a DFD that shows how data will be stored, processed, and transformed in the TIMS system.
2. Draw an FDD that shows the Personal Trainer’s main functions. Also draw a use case diagram that represents the interaction between a user and the proposed TIMS system.
3. Using the information gathered during fact-finding, develop a requirements checklist that includes examples in each of the five main categories.
4. Gray is not familiar with the TCO concept. How should Susan explain it to him?
In: Computer Science
How many integers from 1 to 500 inclusive are
(a) divisible by 6, but are divisible by neither 8 nor 10?
(b) divisible by 6 or 8, but are not divisible by 10?
(c) divisible by 6 and 8, or are not divisible by 10?
In: Computer Science
PROBLEM 5: Code for the Ages Function Name: goldenAges()
The coding language is Jes Python
Parameters: ● list1: a list containing the names of the TAs ● list2: a list containing the ages of the TAs
Return Value: none
Description: I have to concede defeat. It's pretty hard to be creative and reference memes when working with File I/O, so you guys will get to learn something about us you might not already know: our ages!! For this problem, write a function that takes in two lists and writes to a file called "TAages.txt". The function should match the ages to the correct TA and write sentences which say how old each TA is on separate lines. The TA names should be written to the file in reverse order, and the ages written in the same order as your parameter. Remember to close your file at the end!
Test Cases: >>>goldenAges(["Genevieve","Tanya","Khalil","Ryan","Christina"],[19,21,22,21,19])
In: Computer Science
Create a new C# project in Visual Studio. The purpose of this application is to allow the user to open a data file of their choice and your program will retrieve the contents and display them in a ListBox on your Form. Your Form will need an ‘Open’ Button to begin the process, as well as an OpenFileDialog control to allow the user to pick a file of their choice. The OpenFileDialog control should start the user in their ‘C:\’ drive, and should be pre-filtered to only show text files (*.txt). You will also need a ListBox to display the file contents, and the usual Reset and Close Buttons. Be sure to test the application with your own text file. The file you generated in Assessment might be a good choice, but realize I will check it with my own file, which might hold more than just a series of numbers. Since you don’t know the contents of the file, or how many lines there are, make sure that your ListBox is wide enough to handle content as wide as 150 characters per line without horizontal scrolling, and that your file-reading code has the appropriate data validation to determine if the user picked a file or not, and to read *all* the contents of the chosen file, no matter how many lines there are, without going over the end of the file.
In: Computer Science
Write a JAVAprogram that reads a word and prints all its substrings, sorted by length. It then generates a random index between 0 and the length of the entered word, and prints out the character at that index.
For example, if the user provides the input "rum", the program
prints
r
u
m
ru
um
rum
The random index generated is 1. The character at index 2 is u.
In: Computer Science
Stack and Queue
In this question, you will implement a modified version of stackArray class. This modified class requires you to:
• Implement two stacks using a single array. One stack uses the beginning of the array and the other uses the other end.
• Your code should allowing pushes to and pops from each stack by passing the 0 and 1 to any function to identify the needed stack.
• All stack functions should be be applied on both stack. For example, print(0) will print the content of the first stack while print(1) will print the other stack.
• Your stack should contain the following functions at least: isEmpty, isFull, push, pop, top, clear, print and getsize.
• The capacity of the array may be grow depending on the sum of number of objects stored in the two stacks.
• Moreover, the capacity maybe reduced to the half of the current capacity if the number of objects remaining in the two stacks (after each pop) is 1/4 the capacity of the array or less. The capacity of the array may not be reduced below the initially specified capacity.
using C++
this is the stack array code
#define DEFAULT_CAPACITY 10000
template <class T> class StackArray{
public:
StackArray(int capacity = DEFAULT_CAPACITY);
~StackArray();
void push(T& val);
T pop(void);
T top(void);
bool isEmpty(void);
bool isFull(void);
void clear(void);
private:
T* data;
int capacity, last;
};
template <class T>
StackArray<T>::StackArray(int cap){
capacity = cap;
data = new T[capacity];
last = -1;
}
template <class T>
StackArray<T>::~StackArray(void){
delete [] data;
}
template <class T>
void StackArray<T>::push(T& el)
{
if(isFull() )
{
printf("\n Can't push into a full
stack!");
return;
}
last++;
data[last] = el;
}
template <class T>
T StackArray<T>::pop()
{
if(isEmpty() )
{
printf("\n Can't pop from an empty
stack!");
return -1;
}
T el = data[last];
last--;
return el;
}
template <class T>
T StackArray<T>::top()
{
if(!isEmpty() )
{
printf("\n Stack is empty!");
return -1;
}
return data[last];
}
template <class T>
bool StackArray<T>::isEmpty(void)
{
return last == -1;
}
template <class T>
bool StackArray<T>::isFull(void)
{
return last+1 == capacity;
}
template <class T>
void StackArray<T>::clear(void)
{
last = -1;
}
In: Computer Science
The four methods needed for the assignment are specified in the Main class. Include a documentation comment with proper annotations for each of these four methods. Keep in mind that all four methods will be static and void. Additionally, there should be no throws clauses for any of the methods of this program. All exceptions should be properly handled with try-catch blocks. Refer to the following directions for each of the makeFile,readFile, writeFile, and deleteFile methods, respectively:
●Use the createNewFile() method of Java’s File class to add files to a subdirectory (folder)within the project directory. Let the user know if the file was successfully created or if anything goes wrong during the file creation process.
●Read from files using the Scanner class. Be sure to properly handle any exceptions inthe event that the file cannot be found or that the contents of the file cannot be read.Print the contents of the file to the console.
●Write to files using a combination of the FileWriter and PrintWriter classes. New content should be appended to the file rather than overwriting the current contents. Check that the file exists and throw an exception if it does not; do not rely on the PrintWriter class to create a new file to write to. Be sure to properly handle any exceptions in the event that the file cannot be found or that content cannot be written to the file.
●Use the delete() method of Java’s File class to delete files from the subdirectory. Let the user know if the file was successfully deleted or if anything goes wrong during the file deletion process.
The program used is Java script and requires two classes for the project, one- Main class and the second- FileHandler class. the File handler class should be able to create, read, write, and delete files.
public class Main
{
public static void main(String[] args)
{
Scanner keyboard = new
Scanner(System.in); // Scanner object to read user
input
String fileName = "";
// The name of a file to
perform actions on
String content = "";
// Content to be written to a
file
String line = "";
// An
individual line of content
int choice = -1;
// User's
selection
while (choice != 5)
{
System.out.println("1. Create a file\n2. Read from a file\n3. Write
to a file\n" +
"4. Delete a file\n5. Exit the program");
System.out.print("Please enter the number of your selection:
");
choice =
keyboard.nextInt();
keyboard.nextLine();
switch
(choice)
{
// Create a new file
case 1:
System.out.print("Please
enter the name of the new file: ");
fileName =
keyboard.nextLine();
FileHandler.makeFile(fileName);
break;
// Read from a file
case 2:
System.out.print("Please
enter the name of the file to read: ");
fileName =
keyboard.nextLine();
FileHandler.readFile(fileName);
break;
// Write to a file
case 3:
System.out.print("Please
enter the name of the file to write to: ");
fileName =
keyboard.nextLine();
line = "";
do
{
System.out.print("Please enter content to be added to the file
('end' to stop): ");
line =
keyboard.nextLine();
if
(!line.equals("end"))
content += line + "\n";
} while
(!line.equals("end"));
FileHandler.writeFile(fileName, content);
break;
// Delete a file
case 4:
System.out.print("Please
enter the name of the file to delete: ");
fileName =
keyboard.nextLine();
FileHandler.deleteFile(fileName);
break;
// Exit the program
case 5:
break;
// Warning for invalid input
default:
System.out.println("Please
enter a number from 1-5");
}
}
}
}
In: Computer Science
(I need an answer in c++ please / assignment question)
In a double linked chain, each node can point to the previous node as well as the next node.:
a. Define a class to represent a node in a doubly linked chain (UML)
b. Define a class to represent the doubly linked chain (UML), with operations such as:
1. finding its length.
2. add a new Node to the end of the chain.
3. check whether a given Node is included in the Chain (search a node)
4. another operation of your choice.
c. illustrate and list the steps to add to a node to the beginning of the doubly linked chain.
d. illustrate and list the steps necessary to remove the first noe from the doubly linked chain.
In: Computer Science
There's a fine line between white-hat and gray-hat hackers and between gray-hats and black-hats. For instance, some experts consider gray-hat hackers an essential part of securing the Internet because they often expose vulnerabilities before they're discovered by the security community. Research the "definitions" of each of these types of hackers and answer the following questions.
In: Computer Science
write in a long paragraph about the challenges in collecting, managing ,storing, querying, and analyzing various form of big data. use ur own words
In: Computer Science
(python only)
Assignment: Guess a number
To get started, open IDLE and create a New File via the File
menu. We suggest you immediately save this file in the directory
managing all your 102 Python Labs this semester. Please save this
file with the following name: Week9A-guess_number.py.
In this lab, use while loops to create a game where the user of your program guesses a number between 1 and 100. The user keeps guessing until they get it right. You should structure your program as follows:
NOTE: You must use a seed with your random number generator. This will make the grader's life WAY easier.
print("Number to initialize the random generator:")
my_seed = int(input("SEED> "))
random.seed(my_seed)
Sample Execution
Number to initialize the random generator: 32
Enter a number between 1 and 100: 95
OUTPUT You're cold!
Enter a number between 1 and 100: 105
OUTPUT Please Enter a number between 1 and 100
Enter a number between 1 and 100: 41
OUTPUT You're lukewarm!
Enter a number between 1 and 100: 32
OUTPUT You're getting warm!
Enter a number between 1 and 100: 16
OUTPUT You're getting hot!
Enter a number between 1 and 100: 9
OUTPUT You're so close!
Enter a number between 1 and 100: 10
OUTPUT Congrats! You won!
In: Computer Science
equilateral" when all the sides are equal and print "isosceles" when
two sides are equal and print "scalene" when all the sides are
different
In: Computer Science