create a file in java where you can store the first name, last name and the grade of the student. this will repeats until the answer of the question "are you done?" is.equals (y). then write another program that you can read from this file the student's information .
I have dome most of it but my program stores only 1 student's information. WRITE IN FILE
public static void main(String[] args) {
System.out.println("Enter the file name");
Scanner keyboard=new Scanner(System.in);
String fileName= keyboard.next();
boolean done=false;
String response;
PrintWriter output=null;
try {
output=new PrintWriter(fileName);
}
catch(FileNotFoundException e) {
System.out.println ("error in " + fileName);
System.exit(0);
}
while(!done) {
//for (int i=1;i<=2;i++) {
System.out.println("first name:");
String fname= keyboard.next();
System.out.println("Last name:");
String lname=keyboard.next();
System.out.println("Grade:");
double grade=keyboard.nextDouble();
output.println(fname +" "+ lname+" " +grade);
output.close();
System.out.println("Are you done?");
}
String response1 =keyboard.next();
if (response1.equals("y"))
done=true;
}
}
READ THE FILE.
public class ReaderFile {
public static void main(String[] args) throws Exception {
System.out.println("Enter the file name");
Scanner keyboard=new Scanner(System.in);
String fileName=keyboard.next();
File file= new File(fileName);
Scanner input=null;
try {
input= new Scanner(new File(fileName));
}
catch(Exception e) {
System.out.println("Error reading the file" + fileName);
System.exit(0);
}
while(input.hasNext()) {
String fname=input.next();
String lname=input.next();
double grade=input.nextDouble();
System.out.println(fname+" "+lname+" "+grade);
}
}
}
In: Computer Science
3. IEEE Floating Point Representation
What decimal number does the 32-bit IEEE floating point number 0xC27F0000 represent? Fill in the requested information in the blanks below. What is the sign of the number (say positive or negative): What is the exponent in decimal format: What is the significand in binary: What is the value of the stored decimal number in decimal (final answer): Credit will be given for your final answer in the blanks and the work shown below.
In: Computer Science
C-Language
Modify the existing vector's contents, by erasing 200, then inserting 100 and 102 in the shown locations. Use Vector ADT's erase() and insert() only. Sample output of below program:
100 101 102 103
----------------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
// struct and typedef declaration for Vector ADT
typedef struct vector_struct {
int* elements;
unsigned int size;
} vector;
// Initialize vector with specified size
void vector_create(vector* v, unsigned int vectorSize) {
int i;
if (v == NULL) return;
v->elements = (int*)malloc(vectorSize *
sizeof(int));
v->size = vectorSize;
for (i = 0; i < v->size; ++i) {
v->elements[i] = 0;
}
}
// Resize the size of the vector
void vector_resize(vector* v, unsigned int vectorSize) {
int oldSize;
int i;
if (v == NULL) return;
oldSize = v->size;
v->elements = (int*)realloc(v->elements,
vectorSize * sizeof(int));
v->size = vectorSize;
for (i = oldSize; i < v->size; ++i) {
v->elements[i] = 0;
}
}
// Return pointer to element at specified index
int* vector_at(vector* v, unsigned int index) {
if (v == NULL || index >= v->size) return
NULL;
return &(v->elements[index]);
}
// Insert new value at specified index
void vector_insert(vector* v, unsigned int index, int value)
{
int i;
if (v == NULL || index > v->size) return;
vector_resize(v, v->size + 1);
for (i = v->size - 1; i > index; --i) {
v->elements[i] =
v->elements[i-1];
}
v->elements[index] = value;
}
// Insert new value at end of vector
void vector_push_back(vector* v, int value) {
vector_insert(v, v->size, value);
}
// Erase (remove) value at specified index
void vector_erase(vector* v, unsigned int index) {
int i;
if (v == NULL || index >= v->size) return;
for (i = index; i < v->size - 1; ++i) {
v->elements[i] =
v->elements[i+1];
}
vector_resize(v, v->size - 1);
}
// Return number of elements within vector
int vector_size(vector* v) {
if (v == NULL) return -1;
return v->size;
}
void PrintVectors(vector* numberList) {
int i;
for (i = 0; i < vector_size(numberList); ++i)
{
printf("%d ", *vector_at(numberList,
i));
}
printf("\n");
}
int main(void) {
vector numberList;
vector_create(&numberList, 0);
// Populate vector with 101 200 103
vector_push_back(&numberList, 101);
vector_push_back(&numberList, 200);
vector_push_back(&numberList, 103);
// Erase 200 then insert 100 and 102
/* Your solution goes here */
PrintVectors(&numberList);
return 0;
}
In: Computer Science
Using Python, write a program that finds a root of function f(x) = x^2-4x+3 on interval [2,5] using bisection search method. Recall that r is a root of a function if f(r) = 0. Output the number of iterations it took your algorithm to find a root.
In: Computer Science
Topic 1
TRUE OR FALSE Q's
1. Computer software is the collection of programs that provide the instructions that a computer carries out.
2. An abstraction is a mental model that removes or hides complex details.
3. The abacus was the world's first electronic digital computer.
4. Ada Augusta, Countess of Lovelace, is credited with being the first programmer.
5. A vacuum tube was a device used in the third generation of computers.
6. The fourth generation of computer hardware was characterized by large-scale integration.
7. The personal computer was introduced in the fourth generation of computer hardware.
8. The Internet is descended from a U.S. government-sponsored network called the ARPANET.
9. Assembly-language is first generation software.
10. Earliest machine programs were hard wired.
11. Algorithmic thinking is a necessary skill in Computer Science.
12. Computational Science is one of the Systems areas.
13. Spreadsheets and word processors are known as software applications.
14. Applications programmers use the tools built by systems programmers.
15. An algorithm is a set of steps that defines how a task is performed.
In: Computer Science
(Language: PYTHON) Format existing address records and eliminate records with missing critical fields.Critical fields include FirstName, Lastname, Zipcode+4, and Phone number for customers. Use an array to hold data with these 4 fields containing at least 25records. The Zipcode field should contain either traditional 5-digit Zipcode(e.g. 21801)or Zip+4 format(e.g 21801-1101). The phone numbers should contain 10-digit (e.g. 5555555555)or formatted 10-digit(e.g. 555-555-5555). Some records might be corrupt so the data needs to be munged. At this point, we assume only U.S data will be present therefor country code is not needed.
Label each column, properly format the Zip code to be either 11111 or 11111-1111 formats, properly formatthe phone numbers to always be 111-111-1111 format, and replace incorrect values with a blank string.
Notice invalid data was removed and formatting was applied as required. Commas can be left if desired. Default alignment with the column labels is acceptable.
In: Computer Science
For binary data, the L1 distance corresponds to the Hamming distance; that is, the number of bits that are different between two binary vectors. For the following two binary vectors, compute:
X = 10011011
Y = 01011000
1 - Hamming distance
2 - Jaccard Similarity Coefficient (JSC) and Simple Matching Coefficient (SMC)
3 - Cosine Similarity
4 - L2 (Euclidean) and L∞ (Supermum) distances
5 - Correlation between X and Y
In: Computer Science
**C++ Programming Language**
a program that computes the average of a collection of numbers and then outputs the total number of values that are greater than the average. The objective of this assignment is to select a language that you have never used before and modify the program from the text so that it outputs the number of A's, B's, C's, D's and F's. An A grade is any score that is at least 20% greater than the average. The B grade is any score that is not an A, but is at least 10% greater than the average. An F grade is any score that is at least 20% less than the average. The D grade is any score that is not an F, but is at least 10% less than the average. Any scores that are within 10% of the average (either less than or greater than) are C's.
In: Computer Science
Could i please have assistance with the following.
A) TCP/IP protocol stack, how does a switch differ from a hub?
B) How does a switch/bridge know what station is on a given port?
C) What does a switch/bridge do if it does not know the out-going port of a destination MAC address?
D) How is a token ring similar to a Master-and-slave or polling channel access protocol?
In: Computer Science
Design a header file named gshapes.h that contains a namespace named Shapes. The Shapes namespace should contain definitions of at least six inline user-defined functions, each of which computes and returns either volume, or surface area for at least three different geometric shapes of your choice (e.g., cone, pyramid, cylinder, sphere, ...). The gshapes.h header file should be saved within the same project folder that also contains your main program files.
Design the main program that includes the gshapes.h header file and uses the functions from the Shapes namespace. The program will display a menu with at least three geometric shapes' options for the user to select. When the user selects a shape, the program will first obtain the necessary input values for the selected shape, and then call two functions from the Shapes namespace to compute and display the volume and surface area for that geometric shape respectively. The program will then loop back to the main menu for the user to select and process another shape, or to exit the program.
In: Computer Science
Background / Scenario
Attackers have developed many tools over the years to attack and
compromise networks. These attacks take many forms, but in most
cases, they seek to obtain sensitive information, destroy
resources, or deny legitimate users access to resources. When
network resources are inaccessible, worker productivity can suffer,
and business income may be lost.
To understand how to defend a network against attacks, an
administrator must identify network vulnerabilities. Specialized
security audit software, developed by equipment and software
manufacturers, can be used to help identify potential weaknesses.
These same tools used by individuals to attack networks can also be
used by network professionals to test the ability of a network to
mitigate an attack. After the vulnerabilities are discovered, steps
can be taken to help protect the network.
This assignment provides a structured research project that is
divided into two parts: Researching Network Attacks and Researching
Security Audit Tools. Inform your instructor about which network
attack(s) and network security audit tool(s) you have chosen to
research. This will ensure that a variety of network attacks and
vulnerability tools are reported on by the members of the c
In Part 2, research network security audit tools and attack tools. Investigate one that can be used to identify host or network device vulnerabilities. Create a one-page summary of the tool based on the form included within this lab.
Part 2: Researching Network Security Audit Tools and Attack
Tools Step 1: Research various network security audit tools and
attack tools.
Step 2: Fill in the following form for the network security audit
tool/attack tool selected.
Name of tool:
Developer:
Type of tool (character-based or GUI):
Used on (network device or computer host):
Cost:
Description of key features and capabilities of product or
tool:
References and info links:
In: Computer Science
Design the logic in pseudocode for Sign Over Your Money online bank check ordering company as follows: 1. The regular price is $6.95 per box of checks; if the customer orders at least 4 boxes, then the price is $4.95 per box. 2. Standard lettering is included in the price, but if the customer wants either calligraphy or elegant lettering, an additional charge of $3.95 applies. 3. If the customer wants a check register, then an additional charge of $2.95 applies. 4. Shipping and handling charges are $1.95 per box. 5. The program must allow the user to enter a. The number of boxes of checks the customer wants to order b. The type of lettering – standard/calligraphy/elegant (by entering a number from a list, e.g., enter 0 if they want standard lettering, and so on, as shown in the practice exercise solutions) c. Whether the user wants a check register (by responding yes/no to the question when asked) d. The program must output i. The price per box of checks ii. The total price for the number of boxes ordered iii. The type of lettering and the charge for it (if any) iv. Whether a check register is desired and if so, the charge for it v. Shipping and handling charges for the order vi. The total charge for the order Assume that the following constants and variables have been declared, and use them in your code where they apply.
num REGULAR_BOX_PRICE = 6.95 num DISCOUNT_MINIMUM_QUANTITY = 4 num DISCOUNTED_BOX_PRICE = 4.95 num STANDARD_LETTERING_PRICE = 0 num SPECIAL_LETTERING_PRICE = 3.95 num CHECK_REGISTER_PRICE = 2.95 num SHIPPING_HANDLING_PER_BOX = 1.95 num STANDARD_LETTERING = 0 num ELEGANT_LETTERING = 1 num CALLIGRAPHY_LETTERING = 2 string SPECIAL_LETTERING_TYPE_1 = "elegant" string SPECIAL_LETTERING_TYPE_2 = "calligraphy" num boxesOrdered num letteringChoice string letteringType num letteringCharge string registerDesired num registerCharge num boxPrice num totalForBoxes num shippingHandlingCharge num totalCharge
This should be done in pseudocode
In: Computer Science
What are the usages of the following API's/ Macros in contiki ?
In: Computer Science
Write a python program that loops, prompting the user for their full name, their exam result (an integer between 1 and 100), and then writes that data out to file called ‘customers.txt’. The program should check inputs for validity according to the following rules:
The file should record each customers information on a single line and the output file should have the following appearance.
Nurke Fred 58
Cranium Richard 97
Write a second program that opens the ‘customers.txt’ file for reading and then reads each record, splitting it into its component fields and checking each field for validity.
The rules for validity are as in your first program, with the addition of a rule that specifies that each record must contain exactly 3 fields.
Your program should print out each valid record it reads.
The program should be able to raise an exception on invalid input, print out an error message with the line and what the error was, and continue running properly on the next line(s).
You need to develop the system by completing the following three tasks:
Task 1 -
Draw flowchart/s that present the steps of the algorithm required to perform the tasks specified.
Task 2 -
Select at least six sets of test data that will demonstrate the 'normal' operation of your program; that is, test data that will demonstrate what happens when a VALID input is entered.
In: Computer Science
To play the PowerBall lottery, you buy a ticket that has five unique numbers in the range of 1–69, and a “PowerBall” number in the range of 1–26. (You can pick the numbers yourself, or you can let the ticket machine randomly pick them for you.) Then, on a specified date, a winning set of numbers is randomly selected by a machine. If your first five numbers match the first five winning numbers in any order, and your PowerBall number matches the winning Pow-erBall number, then you win the jackpot, which is a very large amount of money. If your numbers match only some of the winning numbers, you win a lesser amount, depending on how many of the winning numbers you have matched.
In the student sample programs for this book, you will find a file named pbnumbers.txt, containing the winning PowerBall numbers that were selected between February 3, 2010 and May 11, 2016 (the file contains 654 sets of winning numbers). Figure 8-6 shows an example of the first few lines of the file’s contents. Each line in the file contains the set of six numbers that were selected on a given date. The numbers are separated by a space, and the last number in each line is the PowerBall number for that day. For example, the first line in the file shows the numbers for February 3, 2010, which were 17, 22, 36, 37, 52, and the PowerBall number 24.
Write a program that works with this file to display the 10 most common numbers, ordered by frequency.
Your submission will consist of:
In: Computer Science