Write a Java program (single file/class) whose filename must be Numbers.java. The program reads a list of integers from use input and has the following methods: 1. min - Finds the smallest integer in the list. 2. max- Finds the largest integer in the list. 3. average - Computes the average of all the numbers. 4. main - method prompts the user for the inputs and ends when the user enter Q or q and then neatly outputs the entire list of entries on one line and then the minimum, maximum, and average. values on separate lines with nice readable labels. 5. Make sure your code runs without error and handles bad inputs and 0 and negative numbers are valid. 6. Followed instructions and include to get full credit file must include your name, date, class and Javadoc code comments for each and every method as well as logic comments.m
In: Computer Science
Java program
Create class DateClass with the following capabilities:
Output the date in multiple formats, such as
MM/DD/YYYY June 14, 1992 DDD YYYY
Use overloaded constructors to create DateClass objects initialized with dates of the formats in part (a). In the first case the constructor should receive three integer values. In the second case it should receive a String and two integer values. In the third case it should receive two integer values, the first of which represents the day number in the year.
If someone enters the day as the 14 and the month is june, the program should be able to convert that to the day out of 365 for the third format. No null values. The program should convert whatever the user enters and print out all three date formats correctly.
In: Computer Science
Task #3 Experimenting with an array of random integers (Week
2)
Make sure that the following 3 experiments are done repeatedly by
generating a new set of integers to fill the array. For this
iterate 10 times and observe results for consistency.
• Make the array size reasonably large (say a thousand) and an even
number.
• Choose the version of nextInt() that allows you to set a cap on
the random integers generated (set it to a few thousands, but way
less than the maximum integer).
• Do the following experiments:
o Count how many integers in the array are odd and even. Are the
odd and even counts almost equal?
o Find the minimum, maximum, and average of the integers in the
array. Keep track of the minimum and maximum of the three
quantities across runs.
o Sort the array by writing an inner and an outer loop. Count the
number of times you needed to swap integers.
In: Computer Science
Using Java
Write only “stubs” for methods in the Figure, Rectangle, and Triangle classes:
Consider a graphics system that has classes for various figures — say, rectangles, boxes, triangles, circles, and so on. For example, a rectangle might have data members’ height, width, and either a center point or upper-left corner point, while a box and circle might have only a center point (or upper-right corner point) and an edge length or radius, respectively. In a well-designed system, these would be derived from a common class, Figure. In this homework assignment, you will implement such a system.
The class Figure is an abstract base class. In this class, create abstract methods for draw, erase, center, equals, and toString.
Add Rectangle and Triangle classes derived from Figure. Each class has stubs for methods erase, draw, and center. In these "stubs", the method simply prints a message telling the name of the class and which method has been called in that class. Because these are just stubs, they do nothing more than output this message. The method center calls the erase and draw methods to erase the object at its current location and redraw the figure at the center of the picture being displayed. Because you have only stubs for erase and draw, center will not do any real “centering” but simply will call the methods erase and draw, which will allow you to see which versions of draw and center it calls. Add an output message in the method center that announces that center is being called. The methods should take no arguments.
Define a demonstration program for your classes which contains main. Test your programs:
In main, make sure that you tell the user what's going on at each step.
Your output should consist primarily of messages from your stub methods. An example of the output from your program might be the following (note: output from main method is shown below in italics):
** Create 2 triangles ** Entering Figure Constructor for triangle 0 Running Triangle constructor for triangle 0 Entering Figure Constructor for triangle 1 Running Triangle constructor for triangle 1 ** Create 2 rectangles ** Entering Figure Constructor for rectangle 0 Running Rectangle constructor for rectangle 0 Entering Figure Constructor for rectangle 1 Running Rectangle constructor for rectangle 1 ** Draw both triangles ** Entering draw() method for Triangle 0 Entering draw() method for Triangle 1 ** Draw both rectangles ** Entering draw() method for Rectangle 0 Entering draw() method for Rectangle 1 ** Center one triangle ** Entering center() method for Triangle 0 center() calling erase() Entering erase() method for Triangle 0> center() calling setCenter() to reset center. Entering Figure's setCenter() for figure 0 center() calling draw() Entering draw() method for Triangle 0 ** Center one rectangle ** Entering center() method for Rectangle 1 center() calling erase() Entering erase() method for Rectangle 1 center() calling setCenter() Entering Figure's setCenter() for figure 1 center() calling draw() Entering draw() method for Rectangle 1 |
In: Computer Science
you are required to use only the functional features of Scheme; functions with an exclamation point in their names (e.g., set!) and input/output mechanisms other than load and the regular read-eval-print loop are not allowed. (You may find imperative features useful for debugging. That’s ok, but get them out of your code before you hand anything in.)
Write a function minMax that, given a list of integers, returns a tuple containing the smallest and largest element in the list. Just return (0 0) for the empty list. > (minMax (5 4 3 2 1)) (1 5)
using the programming language scheme
In: Computer Science
Assume the following JavaScript program was interpreted using static-scoping rules. What value of x is displayed in function sub1? Under dynamic-scoping rules, what value of x is displayed in function sub1?
var x; function sub1() { document.write("x = " + x + ""); } function sub2() { var x; x = 10; sub1(); } x = 5; sub2();
In: Computer Science
Enter a number (0-6): 2
** 2 is Tue **
!!! NO if-else conditions
In: Computer Science
Modify the mortgage program to display 3 mortgage loans: 7 years at 5.35%, 15 year at 5.5%, and 30 years at 5.75%. Use an array for the different loans. Display the mortgage payment amount for each loan. Do no use graphical user interface. Insert comments in the program to document the program.
***********Please look at my code so far. Still having trouble with arrays. Want to know if I'm going the right path********
import java.util.Scanner;
public class MortPay2
{
public static void main(String args[])
{
//declaration section
double principal, monthlyPayment;
int choice;
Scanner input = new Scanner(System.in);
int term [] = {84, 180, 360}; //term in
months
double rate [] = {.0044, .0046, .0048};//rate in
decimal format
//display section
System.out.println("Please select from 3 loan
options.");
System.out.println("1. Loan 1: 7 year term at 5.35%
interest.");
System.out.println("2. Loan 2: 15 year term at 5.5%
interest.");
System.out.println("3. Loan 3: 30 year term at 5.75%
interest.");
choice = input.nextInt();
if (choice ==1)
{
System.out.println("You have chosen
Loan 1.");
System.out.println("Please enter
the loan amount: $");
principal = input.nextDouble();
for ( int i = 0; i<3;
i++)
{
monthlyPayment =
principal * rate[0] / (1.0 - Math.pow (rate[0] + 1),
-term[0]));
System.out.println("Total monthly mortgae payment is $%.2f%n",
monthlyPayment);
}
}
}
}
In: Computer Science
Problem: Implement a class named StringParser, along with specified methods, that can read words from a text file, parse those words (such as finding palindromes), and write those words to a new file More specifically: 1. Write the StringParser class so that it has the following methods: a) public static void main(String[] args) -- The main driver of the program. Prompts the user for an input file, an output file, and a choice for what kinds of words to output. b) public static void rawOutput(File in, File out)-- Parses an input file, writing each word from the input on a separate line in the output file. c) public static void palindromeOutput(File in,File out) -- Parses an input file, writing only the palindromes to the output file, in alphabetical order, one line at a time, without repetition. Palindromes are words that read the same forward and backward, ignoring digits and punctuation. d) public static void hundredDollarWordOutput(File in, File out) -- Parses an input file, writing only the $100 words to the output file, in alphabetical order, one line at a time, in uppercase, without repetition. $100 words are found by assigning $1 to A, $2 to B, and so on. For example ELEPHANTS is a $100 word because: E + L + E + P + H + A + N + T + S is 5 + 12 + 5 + 16 + 8 + 1 + 14 + 20 + 19 = 100 e) public static boolean isPalindrome(String word) -- Determines if a word is a palindrome (reads the same forward and backward). The method is case-sensitive, so it will say that dad and DAD and d-a-d are palindromes, but Dad and d-ad are not palindromes. f) public static String cleanup(String word)-- Takes a string and removes all non-letters, returning an all uppercase version. For example, this input: "A man, a plan, a canal. Panama." will produce this output: "AMANAPLANACANALPANAMA" g) public static int wordValue(String word)-- Returns the monetary value of a word, found by assigning the value $1 to A, $2 B, and so on, up to $26 for Z. The method will ignore differences in case, so both A and a are each worth $1. It will also ignore any non-letters in the input. 2. Create your own input test file, and use it with your code to generate three output files. 3. Upload all five files (Java source code, input file, three output files).
In: Computer Science
Describe the characteristics of situations when generators are a good solution? python
In: Computer Science
PLEASE DO IN JAVA AND USING REPL.IT
Below are the two files, boysNames.txt and GirlsNames.txt
Write a program that reads the contents of the two files into two separate arrays, or ArrayLists. The user should be able to enter a boy’s name, a girl’s name, or both, and the application will display messages indicating whether the names were among the most popular.
BoyNames:
Jacob
Michael
Joshua
Matthew
Daniel
Christopher
Andrew
Ethan
Joseph
William
Anthony
David
Alexander
Nicholas
Ryan
Tyler
James
John
Jonathan
Noah
Brandon
Christian
Dylan
Samuel
Benjamin
Zachary
Nathan
Logan
Justin
Gabriel
Jose
Austin
Kevin
Elijah
Caleb
Robert
Thomas
Jordan
Cameron
Jack
Hunter
Jackson
Angel
Isaiah
Evan
Isaac
Mason
Luke
Jason
Gavin
Jayden
Aaron
Connor
Aiden
Aidan
Kyle
Juan
Charles
Luis
Adam
Lucas
Brian
Eric
Adrian
Nathaniel
Sean
Alex
Carlos
Bryan
Ian
Owen
Jesus
Landon
Julian
Chase
Cole
Diego
Jeremiah
Steven
Sebastian
Xavier
Timothy
Carter
Wyatt
Brayden
Blake
Hayden
Devin
Cody
Richard
Seth
Dominic
Jaden
Antonio
Miguel
Liam
Patrick
Carson
Jesse
Tristan
Alejandro
Henry
Victor
Trevor
Bryce
Jake
Riley
Colin
Jared
Jeremy
Mark
Caden
Garrett
Parker
Marcus
Vincent
Kaleb
Kaden
Brady
Colton
Kenneth
Joel
Oscar
Josiah
Jorge
Cooper
Ashton
Tanner
Eduardo
Paul
Edward
Ivan
Preston
Maxwell
Alan
Levi
Stephen
Grant
Nicolas
Omar
Dakota
Alexis
George
Collin
Eli
Spencer
Gage
Max
Cristian
Ricardo
Derek
Micah
Brody
Francisco
Nolan
Ayden
Dalton
Shane
Peter
Damian
Jeffrey
Brendan
Travis
Fernando
Peyton
Conner
Andres
Javier
Giovanni
Shawn
Braden
Jonah
Cesar
Bradley
Emmanuel
Manuel
Edgar
Erik
Mario
Edwin
Johnathan
Devon
Erick
Wesley
Oliver
Trenton
Hector
Malachi
Jalen
Raymond
Gregory
Abraham
Elias
Leonardo
Sergio
Donovan
Colby
Marco
Bryson
Martin
GirlsNames:
Emily
Madison
Emma
Olivia
Hannah
Abigail
Isabella
Samantha
Elizabeth
Ashley
Alexis
Sarah
Sophia
Alyssa
Grace
Ava
Taylor
Brianna
Lauren
Chloe
Natalie
Kayla
Jessica
Anna
Victoria
Mia
Hailey
Sydney
Jasmine
Julia
Morgan
Destiny
Rachel
Ella
Kaitlyn
Megan
Katherine
Savannah
Jennifer
Alexandra
Allison
Haley
Maria
Kaylee
Lily
Makayla
Brooke
Mackenzie
Nicole
Addison
Stephanie
Lillian
Andrea
Zoe
Faith
Kimberly
Madeline
Alexa
Katelyn
Gabriella
Gabrielle
Trinity
Amanda
Kylie
Mary
Paige
Riley
Jenna
Leah
Sara
Rebecca
Michelle
Sofia
Vanessa
Jordan
Angelina
Caroline
Avery
Audrey
Evelyn
Maya
Claire
Autumn
Jocelyn
Ariana
Nevaeh
Arianna
Jada
Bailey
Brooklyn
Aaliyah
Amber
Isabel
Danielle
Mariah
Melanie
Sierra
Erin
Molly
Amelia
Isabelle
Madelyn
Melissa
Jacqueline
Marissa
Shelby
Angela
Leslie
Katie
Jade
Catherine
Diana
Aubrey
Mya
Amy
Briana
Sophie
Gabriela
Breanna
Gianna
Kennedy
Gracie
Peyton
Adriana
Christina
Courtney
Daniela
Kathryn
Lydia
Valeria
Layla
Alexandria
Natalia
Angel
Laura
Charlotte
Margaret
Cheyenne
Mikayla
Miranda
Naomi
Kelsey
Payton
Ana
Alicia
Jillian
Daisy
Mckenzie
Ashlyn
Caitlin
Sabrina
Summer
Ruby
Rylee
Valerie
Skylar
Lindsey
Kelly
Genesis
Zoey
Eva
Sadie
Alexia
Cassidy
Kylee
Kendall
Jordyn
Kate
Jayla
Karen
Tiffany
Cassandra
Juliana
Reagan
Caitlyn
Giselle
Serenity
Alondra
Lucy
Kiara
Bianca
Crystal
Erica
Angelica
Hope
Chelsea
Alana
Liliana
Brittany
Camila
Makenzie
Veronica
Lilly
Abby
Jazmin
Adrianna
Karina
Delaney
Ellie
Jasmin
In: Computer Science
Create a program that allows a user to input customer records (ID number, first name, last name, and balance owed) and save each record to a file. When you run the main program, be sure to enter multiple records.
Once you create the file, open it and display the results to the user
Save the file as CustomerList.java
In: Computer Science
Everyone, since we covered that the intent of the BIA is to clearly document how each business unit depends upon technology, how does the BIA practically get completed? Is there anyone else other than IT involved?
In: Computer Science
● Write a program that reads words from a text file and displays all the words (duplicates allowed) in ascending alphabetical order. The words must start with a letter. Must use ArrayList.
THE TEXT FILE CONTAINS THESE WORDS IN THIS FORMAT:
drunk
topography
microwave
accession
impressionist
cascade
payout
schooner
relationship
reprint
drunk
impressionist
schooner
THE WORDS MUST BE PRINTED ON THE ECLIPSE CONSOLE BUT PRINTED OUT ON A TEXT FILE IN ALPHABETICAL ASCENDING ORDER IS PREFERRED
THANK YOU IN ADVANCE
import java.util.ArrayList;
import java.util.Arrays;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.Collections;
import java.util.List;
public class ArrayListAscending {
public static void main(String[] args) {
try {
File j = new
File("C:\\Users\\NaharaY\\Dropbox\\Jesse -23263\\Introduction to
Software Engineering\\Task 20\\words.txt");
Scanner input =
new Scanner(j);
List<String>list = new ArrayList<String>();
String line =
"";
while(input.hasNext()) {
list.addAll(Arrays.asList(line.split("
")));
}
Collections.sort(list);
for(String
temp:list) {
if(temp!=null &!temp.equals(""))
if(Character.isLetter(temp.charAt(0)))
System.out.println(temp);
}
input.close();
}catch(FileNotFoundException e)
{
System.out.println("Error");
}
}
}
In: Computer Science
Find global or domestic operating system market share information, that shows the market share of Windows 7, 8, and 10. Using that information, answer this question: How successful is Windows 7 compared with other versions of Windows?
In: Computer Science