I'm not sure why, but my program does not produce an output. It is supposed to output total charges.
/*This program provides the user with the price of their monthly internet service based on two inputs.The program asks users which subscription they have. The options are A, B, or C. This is the first input.
The program then will ask the user how many hours they used the internet for. This is the second input.Then, based on the package number, the program will compute their monthly bill. This is the output.
The program calculates the price based on the following prices:
Package A: For $9.95 per month, 10 hours of access are provided. Additional hours are $2.00 per hour. Package B: For $13.95 per month, 20 hours of access are provided. Additional hours are $1.00 per hour. Package C: For $19.95 per month, access is unlimited.*/ import java.util.Scanner; public class Lab03SV
I'm having some trouble with getting this program to read an input of morse code and then produce an output of English. When typing in morse code for the phrase 'the string', the output looks something like this:
I am working on a personal project and want to create a text editor to write my code. I am wondering how could I read the last input from the user and if say it was an open curly brace {, then like netbean's my editor will supply the closing curly brace. My java experience is limited but I have tried to read key board input and a few other options that did not work.
So I have 2 args[] one that reads the file name in the same directory and the other that tries to count how many of any letter (maybe even words) in the txt file ....
I need to read the contents of file A, and B and store it in file C by joining the contents of A and B and also counting the number of letters/characters present in it.
I've come up with this so far.
import java.io.FileInputstream; import java.io.FileNotFoundException; import java.io.IOException; public class JavaApplication43{ public static putwrite(string fname) throws FileNotFoundException, IOException
I have been working on this for hours and cannot get it to work properly. The program is to count the number of characters contained in both strings and display the results. It is also to display the final statement, but only once. This version has a complete statement for each matching character.
import java.util.Scanner; public class CountMatches { public static void main(String[] args) { String firstStr = (""); String s1 = firstStr;
I've looked around a bit myself online (admittedly for only a few minutes) and have yet to come across a straight-forward object for date selection. Does Java offer something like that?what should be a simple task?
Right now I have 12 methods, each roughly 40 lines long, and I am contemplating whether I should simplify some of the pairs (12 methods, but every other method is very similar to each other, so 6 pairs) into one method.
The main pro of simplifying them is that my class will be much smaller, right now its about 555 lines of code. However a con is that it might not be as straight forward, at first glance at least.
Here is what I am talking about. Two original methods that are very similar:
void rotateRightClockwise(int rotations){//rotates FRONTS's RIGHT! CONFIRMED String a, b, c;//temp values for(int i = 1; i <= rotations; i++){//confirmed a = cube.cube[1][2].square[2];//3 b = cube.cube[1][2].square[5];//6 c = cube.cube[1][2].square[8];//9
[Code] ....
The only difference between these two methods, other than the last chunk for each method, is the I have to change the 2nd square bracket, [], values from lines 9-23 for cube[][]. That's it. So I am thinking of combining them into something like this...
private void rotateRight(int rotations, int x, int y){ String a, b, c;//temp values for(int i = 1; i <= rotations; i++){//confirmed a = cube.cube[1][2].square[2];//3 b = cube.cube[1][2].square[5];//6 c = cube.cube[1][2].square[8];//9
[Code] .....
And then after calling this similar method, I would finish off the last chunk from each methods, since they are too different (ie lines 26-38).
The reason why I ask this is because I am trying to build up my portfolio and I want to know if the employer would look at this and say "that was a good move by compacting your code" or "this is not that straight forward".
I've been working on a personal project again in Unit 3 of my text book and this time they want me to make a random phone number generator. Here's the actual directions:
"Write an application that creates and prints a random phone number of the form XXX-XXX-XXXX.
Include the dashes in the output.
Do not let the first three digits contain an 8 or 9 (but don't be more restrictive than that), and make sure that the second set of three digits is not greater than 742.
Think through the easiest way to construct the phone number. Each digit does not have to be determined separately."
With this assignment I came across 2 problems:
1. What I tried was that since the first 3 numbers have to be a random number with no 8's or 9's I tried doing this algorithm:
The problem is that Java won't allow me to generate random numbers this way. Are there any easier ways of generating numbers that doesn't contain specific number (such as 8 or 9 in this case?)
2. I was thinking about this throughout the whole project and what if I generate a number such as 27 (less than 3 or 4 digit number) rather than 3 or 4 digit numbers? How would it show 0027 or 027 instead of 27 for the phone numbers?
import java.util.Random; public class pp0303 { public static void main (String[] args){ Random generator = new Random(); int first0, first1, first2, second, third, random0;
[Code] ....
RESULTS:
Exception in thread "main" java.lang.Error: Unresolved compilation problems: Cannot invoke replace(char, int) on the primitive type int Cannot invoke replace(char) on the primitive type int Syntax error on token "random0", delete this token at pp0303.main(pp0303.java:15)
Using JOptionPane,ask for 10 numbers from the user.Use an array to store the values of these 10 numbers.Output on the screen the number with the greatest value.
Write a program that prompts the user to input an integer and then outputs both the individual digits of the number and the sum of the digits.
Now I have a code for spacing out the integers, and I have a separate code for adding the digits. But I am not sure how to merge them together. Both of them work independently
Spacing code: import java.util.*; public class SumoftheIntegers { static Scanner console=new Scanner(System.in); public static void main(String []args) { int num1, test, rem; int counter = 0;
[Code]...
Now the sum of the integers code:
import java.util.Scanner; public class sum { public static void main(String[] args) { // Create a Scanner Scanner input = new Scanner(System.in); // Enter amount System.out.print("Enter an integer: "); int integer = input.nextInt();
public class CollisionManager<T> { private boolean collision = false; private T mainEntity; public <T extends Entities> void handleCollision(T mainEntity, T secondEntity){ this.mainEntity = mainEntity; // This is illegal. } }
Why "this.mainEntity = mainEntity" is incorrect and also show me the correct way to achieve this?
The error I am getting is "Type mismatch: cannot convert T to T"
Write a function (or functions) that given a collection of files will produce a sum of integers from each line of each file. Each file can have any number of lines from 1 to N. Each line can contain only one integer and no other alphanumeric characters. All of the numbers from all of the files should be added to the final result. The result is just one number.
I have a question: I have a Java/JSP/JavaScript project that access back end Oracle database, and provide interaction through tomcat. After we deployed our project, I found one button does not generate necessary warning message from server, but when I deployed and tested our project on local PC, it does generate correct warning message. I am using the same IE, same tomcat version, and I am sure my container is pointing to the same database, and I am sure I using same version of project code by checking with GIT.
public class RealignServlet extends SiapBaseServlet { private static final long serialVersionUID = 1L; private static final Logger logger = AppLogger.getLogger(RealignServlet.class.getName()); private static final String PROC_QUERY_JSP = "ProcQuery.jsp"; private static final String REALIGN = "REALIGNMENT";
[Code] .....
Our problem is server could not generate alignMsg. But we can get it on local deployed project.
I've been working on a question using parallel arrays where the user inputs an integer 1-12 and the output will be the name of the month and the number of days in that month. This is what I have so far
import java.util.*; public class DaysMonth { public static void main (String args[]) { Scanner keyIn = new Scanner(System.in); int[] days = new int[]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
I cannot get the right output for my program. I need to get the total number of pennies in dollar amount for the output of Total Pay. This is my program. The directions are:
Write a program that calculates the amount a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, and continues to double each day. The program should then show the total pay at the end of the period. The output should be displayed in a dollar amount, not the number of pennies. Do not accept a number less than 1 for the number of days worked.
import java.util.Scanner; import java.text.DecimalFormat; public class PenniesForPay { public static void main(String[] args) { int numDays;
[Code] ....
totalSalary should be total number of pennies / 100....However its not picking up only day 30 of pennies which is 536,870,912 pennies and then dividing it?
I am having an array of strings and i want to find out whether these strings contained in the array contain a similar character or not.For example i am having following strings in the array of string:
aadafbd dsfgdfbvc sdfgyub fhjgbjhjd
my program should provide following result: 3 because i have 3 characters which are similar in all the strings of the array(f,b,d).
The intentions of this program is to prompt a user to enter a file name, and then reads the file. The program will prompt the user to enter a word that needs to be corrected. So lets say I have a text file containing "My name is OP and I Like goind to the Park!" I want to change "goind" to "going",
Now, my second method "isSimilar" executes a similar word with more than one same letter and same length, but I dont know how to execute that whole thing in my third method "correctThisLine" . How I can call that isSimilar method and read in that text file and change that word into that?
import java.util.*; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class WahidMuhammadA3Q2{ String fileName = "AutoCorrectMe.txt"; public static void main (String [] args){