i got this error when I try to compile my code. What should I do? Should i change the name of my file (CompactDisc.java) to another? I already created a Song.java file, what command or action should I make next. CompactDisc.java:49: error: class Song is public, should be declared in a file named Song.java public class Song ^ 1 error
Q: Add a method called save to your Person class. This method will write the object out to a binary…
A: Answer: I have done your code which have given nothing else
Q: Using the card.java class file, write a program to simulate a Deck of Cards. See Programming…
A: PROGRAM CODE: import java.util.Scanner; public class Main { public static void main(String[]…
Q: 2. Complete the class code below and using only the main method, add code to make an EXACT COPY of…
A: [Note: Explanation of the program code is provided within the comments.] Program code:…
Q: The program will READ in data from a text file named StudyHours.txt. The user corrects any bad data.…
A: Actually, given information: The program will READ in data from a text file named StudyHours.txt.…
Q: 3. Write a Java application class that does the following: Input a text file name entered by the…
A: public class HotelRoom { // attributes private int roomNo; private String phoneNumber;…
Q: This is in Java please: A comma separated value (.csv) file has been included to be used for this…
A: Actually, java is a object oriented programming language.
Q: Java programming
A: import java.io.FileNotFoundException; import java.util.Scanner; public class LongestLineMain {…
Q: ame, address, city, zip, phone number, email, hourly rate, start date, end date, and number of hours…
A: I have used multi-level inheritence logic to make your program, Kindly check the attached code and…
Q: SpyEncoder inherits from Spy parent class one public method encode(input_file_name,…
A: The Code of the following is given below.
Q: need help: Write a complete working java program in a class named Driver that opens a file named…
A: Required: I need help: Write a complete working java program in a class named Driver that opens a…
Q: This is to be programed in java You will create a driver file called personalInfo.java…
A: Here I have created the class Person with attributes and constructor. Then, I have created a method…
Q: I'm new to Java) and I am really trying to better understand reading code and the logic/ code…
A: Question 1: why I need a separate Main public class. I'm wondering why I can't include it in the…
Q: Ok, I am trying to understand what is being asked next / how to do it for my Java assignnment...…
A: Also create a get method that returns one of the Student's CollegeCourses; the method takes an…
Q: e make, YYYY is the year it was manufactured, C is the first letter of the colour and XX is the…
A: Create a simple java program that reads all the content in a .txt file, the user will enter the…
Q: Create a class named TestMovie that creates three movie instances with different values for name and…
A: Algorithm: Created a class, Movie which holds two data members movieName and rating. Created…
Q: a simple java program that reads all the content in a .txt file, the user will enter the filename to…
A: It is defined as a high level, robust, object-oriented and secure programming language. It is known…
Q: In a Python file called icecream.py, write a class called IceCream that matches the following…
A: Use a constructor to create instance where we set the price_per cup and then in get_cost method we…
Q: ** Attached with this assignment two classes: Student (in file Students.java) and Faculty (in file…
A: ⦁ Here we have to construct a java program to enter the student details and the faculty details and…
Q: What is the stored in the object obj in following lines of Java code? box obj;
A: Please comment in case of any doubt.
Q: (Intro to Java) explain the answers to the below questions using step-by-step explanation. Assume…
A: According to the Question below the Solution:
Q: Suppose a Student class has the following attributes and methods: Student: int id (public), String…
A: The java program is given by import java.io.*; import java.util.*; class Student { publicint id;…
Q: implement the program as described and submit as a .java file. Roman numbers. Write a program that…
A: Purpose of the program: This program obtains the equivalent Roman literals for a given positive…
Q: What will be the output of the following Java code? import java.io.*; class files { public static…
A: Question. What will be the output of the following Java code? import java.io.*;class files{public…
Q: write a Java program WITHOUT USING THROWS IN THE MAIN METHOD: The following is an old word puzzle:…
A: Use Scanner to read contents from file line by line and then check whether string ends with…
Q: What
A: An object is a real world entity For eg. A Fruit class can have object like- Apple, Banana, Mango…
Q: Is the following true or false IN JAVA In java it is possible to throw an exception, catch it, then…
A: In java it is possible to throw an exception, catch it, then re-throw that same exception if it is…
Q: Write a java program and also attach SS of output. Why do we need encapsulation? What happens if…
A: Encapsulation is the process of wrapping the data and code together as a single unit. Because of…
Q: In the main class first Create three departments. Ask the user to input the field values. In the…
A: The question is about designing the classes for Department, Student and University and taking user…
Q: Please help me with this assignment below. I already have the code, you just need to fix something…
A: According to the question, we need to return only those spellings that are in words.txt file. Since…
Q: Let's create our first Java file, called Welcome.java, which can be done in any text editor (like…
A: Given: Output of Java Program.
Q: Write a simple java program in which you have to implement all the java stringbuffer method listed…
A: Sample Response: //Java program to implement all the java stringbuffer methods such as capacity(),…
Q: JAVA - Please produce both a product.java file and a productprinter.java file (tester) Implement a…
A: public class mainClass { public static void main(String[] args) { emp pcost = new emp();…
Q: Write a Java program in a file called Box.java that outputs a box of stars (*) on the screen.…
A: import java.util.Scanner;class Test147 { public static void main(String args[]) { Scanner sc = new…
Q: Need Help For Java. Thanks. Suppose that the class Score is defined as class ScoreInfo {…
A: Import stream collector, array, list package. The Main class consists of data to store the student…
Q: Computing a positive integer power of a number is easily seen as a recursive process. Consider an:…
A: According to the question below the complete Program: Program Output:
Q: import java.util.Scanner; public class LabProgram { public static void main(String[] args) {…
A: Actually, Java is a high level programming language. And also object oriented .It Is a platform for…
Q: Write one word answers for the following: a.On compiling a file with the name “Demo.java” having a…
A: a) In Java, the java file name ought to be continuously a similar as a public category name. whereas…
Q: ant note: your code must compile correctly and run without errors. Otherwise, your code will get the…
A: It is defined as one of the most popular programming languages that is being widely used in the IT…
Q: a console application for writing data to a sequential text file with a formatter class in Java :
A: 1. create a class to define the file.2. take the location of file from user.3. use catch and throw…
Q: Write a Java class called PersonalizedHelloWorld that prompts a user for their name and then…
A: we solve the above task by following steps: STEP-1 First Create an instance of Scanner class for…
Q: Write a java program to demonstrate the knowledge of students in File handling. Eg., Define a…
A: Given: Write a java program to demonstrate the knowledge of students in File handling. Eg., Define…
Q: Based on the java source code given , how can i add a simple payment system in the code. Please…
A: Errros
Q: Assume class ArrayStack has been defined using the implementation in your textbook and that myStack…
A: Below is the answer with explanation:
Q: Which of the following is true about blocks in java
A: Java is the most popular and widely used object oriented programming language. It is used as the…
Q: Write method for searching the grade of the student whose ID is given.
A: I have answered Part I
Q: In Java intellej Correct this code and add the following 1.Correct: (The error shows a…
A: import java.nio.file.FileStore; import java.util.Scanner; class Image { int numberOfPhotos; //…
Q: Create a simple java program that reads all the content in a .txt file, the user will enter the…
A: Program Explanation: 1) Implement the header file. 2) Declare the integer and assign the values. 3)…
Q: Write a client program that allows the user to add up any number of non-zero fractions. The program…
A: An object of the class Fraction is made as f_s with value as fractions.get(0). Another object of the…
Q: In this code which part I will keep main.java file and which part I will keep…
A: Note : Save the code below as unsortedArrayAccess.java in the compiler. SOURCE CODE import…
i got this error when I try to compile my code. What should I do? Should i change the name of my file (CompactDisc.java) to another? I already created a Song.java file, what command or action should I make next.
CompactDisc.java:49: error: class Song is public, should be declared in a file named Song.java public class Song ^ 1 error
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- In Java The following is a java code for an old word puzzle: “Name a common word, besides tremendous,stupendous and horrendous, that ends in dous.” If you think about this for a while, it will probablycome to you. However, we can also solve this puzzle by reading a text file of English words andoutputting the word if it contains “dous” at the end. The text file “words.txt” contains 87314English words, including the word that completes the puzzle. This file is available on Moodle.Your job is to insert try-catch statement in the below code, such that you surround the “risky” APIwith an appropriate exception handler --Edit the code if you have to!// import IO and util packages.public class WordPuzzle{public static void main(String[] args){String s;Scanner scanner = new Scanner(Paths.get("words.txt"));while (scanner.hasNext()) { String word = scanner.next(); if (word.endsWith("dous")) System.out.println(word); } // end while} // end main} // end classi got this error when I try to compile my code. What should I do? Should i change the name of my file (CompactDisc.java) to another? I already created a Song.java file, what command or action should I make next. import java.io.*; /** This program creates a list of songs for a CD by reading from a file.*/ public class CompactDisc{ public static void main(String[] args)throws IOException { FileReader file = new FileReader("Classics.txt"); BufferedReader input = new BufferedReader(file); String title; String artist; Song[] cd= new Song[6]; // ADD LINES FOR TASK #3 HERE // Declare an array of Song objects, called cd, // with a size of 6 for (int i = 0; i < cd.length; i++) { title = input.readLine(); artist = input.readLine(); //Song dc= new Song(title,artist); cd[i]= new Song(title,artist); // ADD LINES FOR TASK #3 HERE // Fill the array by creating a new song with…Write a program in Java to perform the following: Using a BufferedReader class and related objects, read a string object consists of 60 words plus some special characters and numbers. Include double space between some words. Include a few $ and % signs in your text. Store that text into a file using proper classes and methods. Call that file fileon.doc which will be your input file then read the contents of that file and perform the following operations using java available methods: Add a new line at the beginning of the text to include your name and the class name (csc 202) Find the length of you text Change the first character of each line to upper case . Find the number and location of all $ sign and re place it with a space. Delete all double spaces Calculate the number of special characters Find the number of lines in your text. Remember each line is terminated by a “.”, find the number of vowel in the last line Count the number of digits in your text. Append a new line consist…
- Java: Below are 3 java files along with a text file. Make sure in the console, shank.txt is read into tokens. Make sure to show the 3 java files with the screenshot of shank.txt being printed out in the console. The output must show shank.txt being printed out in tokens. There must be no error at all. Main.java import java.io.IOException;import java.nio.file.Files;import java.nio.file.Paths;import java.util.List; public class Shank { public static void main(String[] args) { if (args.length != 1) { System.out.println("Error: Exactly one argument is required."); System.exit(0); } String filename = args[0]; try { List<String> lines = Files.readAllLines(Paths.get(filename)); Lexer lexer = new Lexer(); for (String line : lines) { try { List<Token> tokens = lexer.lex(line); for (Token token : tokens) { System.out.println(token); } } catch (Exception e) { System.out.println("Exception: " + e.getMessage()); } } }…Hey, this is my code below and I cannot seem to get the import.java.io.*; to create and save information on a txt file. Any help would be great. There is a person class with get and set for firstname, lastname, etc. However I could not fit it in due to space. Code in bold is what I tried for the txt. import java.io.FileNotFoundException;import java.io.PrintWriter;import java.util.ArrayList;import java.util.Scanner; import mainInterface.Interface; public class StaffManager { protected static ArrayList<Staff> Staffs = new ArrayList<Staff>(); public static void main(String[] args) throws FileNotFoundException{ staffManMenu(); //Call writeToFile writeToFile(); } // method to write the staff data to a file titled StaffFile.txt public static void writeToFile() throws FileNotFoundException{ //create object PrintWriter write = new PrintWriter(new File("StaffData.txt")); for(Staff s : Staffs) { write.println("First Name: "…In this code which part I will keep main.java file and which part I will keep unsortedArrayAccess.java file. Because I will use main.java IDE. Otherwise my program doesn't run. Also give me a link which compiler I can correctly run without any errors. If you don't know how you can figure out, please just reject. import java.util.*; public class unsortedArrayAccess{ public static double[] arr; public int arraySize; public unsortedArrayAccess(int scale) { arr = new double[scale]; arraySize = 0; } public int search(double Key) { int i = 0; while ((i < arraySize) && (arr[i] != Key) ) { i = i + 1; } if (i < arraySize) { return i; } else { System.out.println("There is no such item!"); return -1; } } public void append(double Item) { arr[arraySize] = Item; arraySize = arraySize + 1; } public double remove() { if (arraySize == 0) { System.out.println("There is no item in the array!");…
- Please use JAVA code to write the solution, thanks A text file called names.txt contains one name per line, e.g.,AllisonJohnWilliamJohnetc.Names can be duplicated in the file. Write the code that:1. Reads the names line by line.2. Stores each name and the number of times the name appears in one collection.3. Prints the number of different names to the console.4. Prints the names and how many times each name appears on the console.Think about what data structure would work in associating each name with the number of times it appears in the file. You do not need to write imports.Write a java program in a single file that: Main: Creates 10 random doubles, all between 1 and 11, Calls a method that writes 10 random doubles to a text file, one number per line. Calls a method that reads the text file and displays all the doubles and their sum accurate to two decimal places.I am trying to figure out why the sum at the end of my Java code is not working correctly. It keeps showing as zero and I do not know what the issue is. Here is the program requirements Write a program in a single file that: Main: Creates 10 random doubles, all between 1 and 11, Calls a method that writes 10 random doubles to a text file, one number per line. Calls a method that reads the text file and displays all the doubles and their sum accurate to two decimal places. SAMPLE OUTPUT 10.62691196041722.7377903389094555.4279257388651281.37420580654725091.18587002624988364.1803912764852284.9109699989306755.7108582343439587.7908570073730523.1806714736219543 The total is 47.13 Here is my code:
- I am trying to figure out why the sum at the end of my Java code is not working correctly. It keeps showing as zero and I do not know what the issue is. Here is the program requirements Write a program in a single file that: Main: Creates 10 random doubles, all between 1 and 11, Calls a method that writes 10 random doubles to a text file, one number per line. Calls a method that reads the text file and displays all the doubles and their sum accurate to two decimal places. SAMPLE OUTPUT 10.62691196041722.7377903389094555.4279257388651281.37420580654725091.18587002624988364.1803912764852284.9109699989306755.7108582343439587.7908570073730523.1806714736219543 The total is 47.13 Here is my code: import java.util.*;import java.io.*; public class AssignmentTwo { public static void main(String[] args) {//main method double randNum [] = new double [10]; for(int i = 0; i< randNum.length; i++) { randNum[i] = (double)(Math.random()* (10) + 1);…Let's create our first Java file, called Welcome.java, which can be done in any text editor (like Notepad, Notepad++, Visual code, etc.). Open a file and paste the following Java code. public class Main { public static void main(String[] args) { System.out.println("mudau shudufhadzo welcome to BIS2142/ 2542 class"); } } Execute/ run it using a command prompt. Your output should contain a name and welcome to BIS2142/ 2542 class message. Therefore, your display message will look like this "mudau shudufhadzo "welcome to BIS2142/2542 class".In Java Suppose you are given a text file that contains the names of people. Every name inthe file consists of a first name and a last name. Unfortunately, the programmer thatcreated the file of names had a strange sense of humor and did not guarantee thateach name was on a single line of the file. Write a program that reads this file ofnames and writes them to the console, one name per line.For example, if the input file (Names.txt) contains:Bob Jones FredCharles EdMarstonJeffWilliamsThe output should be:Bob JonesFred CharlesEd MarstonJeff Williams Sample Output:Enter the name of the input file:Names.txtBob JonesFred CharlesEd MarstonJeff WilliamsFile processing completed.