|
Letter Counter
Write a program that asks the user to enter a string, and then asks
the user to
enter a character. The program should count and display the number of
times
that the specified character appears in the string.
|
|
import
java.util.*;
/*
* Course: ITECH 2120_Intro of programming
JAVA
* Instructor: Dr. Tacksoo Im
* Project: Letter count_Assignment3
* Author: Mohan Maharjan
* Date: October 14 2013
* Version: 1
*/
public class
LetterCounter
{
public static void
main(String[] args)
{
Scanner scan = new
Scanner(System.in);
//users to write a letter
System.out.println("Please
write a short letter");
String letter = scan.nextLine();
// users to enter a word to count
System.out.println("Please
type a word to count");
char countChar
= scan.next().charAt(0);
int count =0;
for (int i = 0; i
<letter.length(); i++)
{
if
(letter.charAt(i)== countChar)
{
count++;
}
}
System.out.println("The
total matched word "+ countChar +
" appears in the letter =
" + count);
scan.close();
}
}
|
|
Running the Race
Write a program that asks for the names of three runners and the
time, in
Minutes, it took each of them to finish a race. The program should
display the
names of the runners in the order that they finis
|
|
import
java.util.*;
/*
* Course: ITECH 2120_Intro of programming
JAVA
* Instructor: Dr. Tacksoo Im
* Project: Running the Race_Assignment3
* Author: Mohan Maharjan
* Date: October 14 2013
* Version: 1
*/
public class
RunningTheRace
{
public static void
main(String[] args)
{
String
firstPlace,secondPlace,thirdPlace, firstName, secondName, thirdName;
double
firstRunner, secondRunner, thirdRunner;
System.out.println("This
application is created to display runners' position."+"\n" +"NO
ties possible between them.");
//get the first runner's info
Scanner scan = new
Scanner(System.in);
System.out.println("#1
Please enter your name: ");
firstName =
scan.nextLine().toUpperCase();
System.out.println("#1
Enter your finishing time: ");
firstRunner = scan.nextDouble();
//get the second runner's info
Scanner scan2 = new Scanner
(System.in);
System.out.println("#2
Please enter your name: ");
secondName =
scan2.nextLine().toUpperCase();
System.out.println("#2
Enter your finishing time: ");
secondRunner = scan2.nextDouble();
//get the third runner's info
Scanner scan3 = new
Scanner(System.in);
System.out.println("#3
Please enter your name: ");
thirdName =
scan3.nextLine().toUpperCase();
System.out.println("#3
Enter your finishing time: ");
thirdRunner = scan3.nextDouble();
//determine for the first position
if(firstRunner
< secondRunner && firstRunner < thirdRunner)
{
firstPlace = firstName;
}
else if(secondRunner
< firstRunner && secondRunner < thirdRunner)
{
firstPlace = secondName;
}
else
{
firstPlace = thirdName;
}
//determine
for the first position
if(firstRunner
< secondRunner && firstRunner > thirdRunner)
{
secondPlace = firstName;
}
else if(firstRunner
< thirdRunner && firstRunner > secondRunner)
{
secondPlace = firstName;
}
else if(secondRunner
< firstRunner && secondRunner > thirdRunner)
{
secondPlace = secondName;
}
else if(secondRunner
< thirdRunner && secondRunner > firstRunner)
{
secondPlace = secondName;
}
else
{
secondPlace =
thirdName;
}
//determine for the first position
if(firstRunner
> secondRunner && firstRunner > thirdRunner)
{
thirdPlace = firstName;
}
else if(secondRunner
> firstRunner && secondRunner > thirdRunner)
{
thirdPlace = secondName;
}
else
{
thirdPlace = thirdName;
}
//printout the result
System.out.println("Congratulations!
"+ firstPlace + ", you are the first Position.");
System.out.println("Congratulations!
"+ secondPlace + ", you are the second
position.");
System.out.println("Congratulations!
"+ thirdPlace + ", you are the third position.");
scan.close();
scan2.close();
scan3.close();
}
}
|
Latest Post
java program: letter counter and running the race
Written By Unknown on Tuesday, October 8, 2013 | 11:00 AM
Create program to display your current age; Write a Java program that asks the user for the user's annual salary.
|
Create a Java program that prompts the user
for the year they were born in and prints out their current age.
|
|
import
java.util.Calendar;
public class YourAge
{
public static void
main(String[] args)
{
Scanner scan = new Scanner(System.in);
System.out.println("Please enter the year of
your birth");
Calendar now = Calendar.getInstance();
int year =
scan.nextInt();
int age =
now.get(now.YEAR) - year;
System.out.println ("Your age is " + age );
scan.close();
}
}
|
|
Write a Java program that asks the user for
the user's annual salary (e.g $250,000). Print out the following based on the
user's salary. 1. Social security tax (7% of the salary) 2. Federal tax (20%
of the salary) 3. State tax (10% of the salary) 4. Tax return (30% of the
total paid taxes) 5. Annual income after taxes (includes the tax return)
Partial credit is given but the standards are much higher for the extra
credit problems
|
|
import
javax.swing.*;
public class
AnnualSalary
{
public static void
main(String[] args)
{
String salary = JOptionPane.showInputDialog("Please
enter your total income ");
//String salary =
"250000";
int i =
Integer.parseInt(salary);
double
socialSecurity = Double.parseDouble(salary) * .07;
double
federalTax = Double.parseDouble(salary) * .2;
double stateTax
= Double.parseDouble(salary) * .1;
double totalTax
= socialSecurity + federalTax + stateTax;
double afterTax
= i - totalTax;
double taxReturn
= totalTax * .3;
double
totalIncome = afterTax + taxReturn;
//System.out.println("Your
total annual income is = $ " + totalIncome);
JOptionPane.showMessageDialog(null, "Your
total annual income is = $ " + totalIncome);
}
}
|
Measurement and Significant Figures Practice
Written By Unknown on Tuesday, August 20, 2013 | 12:46 PM
1. How many significant figures are in the measurement 102.400 meters?
A. five B. three C. six D. four
2. Convert the following measurement to scientific notation: 101 000 grams
A. 1.01 x 105 g B. 1.0100 x 10-5 g C. 1.01000 x 105 g D. 10.1 x 104 g
3. Solve: 3.12 g + 0.8 g + 1.033 g = ?
A. 4.953 g B. 5.0 g C. 4.9 g D. 5 g
4. The volume of liquid being measured in the graduated cylinder is:
A. 8.000 cm3 B. 8.0 cm3 C. 8.00 cm3 D. 8.50 cm3
5. Solve: 923 g divided by 20 312 cm3 = ?
A. 0.045 g/cm3 B. 0.04 g/cm3 C. 4.00 x 10-2 g/cm3 D. 0.0454 g/cm3
6. How many significant figures are in the measurement 0.00130 cm?
A. four B. five C. three D. two
7. Subtract: 7.987 m - 0.54 m
A. 7.5 m B. 7.45 m C. 7.4 m D. 7.447 m
8. The arrow denotes the measured point:
A. 2.530 cm B. 2.8 cm C. 2.80 cm D. 2.53 cm
9. The length of the red line measured here is:
A. 5.65 cm B. 5.5 cm C. 5.712 cm D. 5.7 cm
10. Solve: 345.009 g - 23.009 g = ?
A. 322 B. 322.00 g C. 322 g D. 322.000 g
11. The mass of a watch glass was measured four times. The masses were 99.997 g, 100.008 g, 100.011 g, and 100.005 g. What is the average mass of the watch glass?
A. 100.0 g B. 100.01 g C. 100.00525 g D. 100.005 g
12. Round the following measurement to three significant figures: 0.90985 cm2
A. 0.910 cm2 B. 0.909 cm2 C. 0.9099 cm2 D. 0.91 cm2
13. Complete the following problem: A piece of stone has a mass of 24.595 grams and a volume of 5.34 cm3. What is the density of the stone? (remember that density = m/v)
A. 4.606 g/cm3 B. 4.61 g/cm3 C. 0.22 cm3/g D. 0.217 cm3/g
14. Solve: 13.004 m + 3.09 m + 112.947 m = ?
A. 129 m B. 129.0 m C. 129.04 m D. 129.041 m
15. Solve: 123 000 m x 3 234 m = ?
A. 398 m2 B. 3.97 x 10-7 m2 C. 3.98 x 108 m2 D. 39800000 m2
16. When performing the calculation 34.530 g + 12.1 g + 1 222.34 g, the final answer must have:
A. Three significant figures B. Units of g3 C. Only one decimal place D. Three decimal places
17. When measuring the length of this red line with the metric ruler provided, the first decimal place that is uncertain is:
A. thousandths of centimeter B. tenths of a centimeter C. hundredths of a centimeter D. meters
18. Solve: 1.23 m x 0.89 m = ?
A. 1.1 m2 B. 1.0947 m2 C. 1.0 m2 D. 1.09 m2
19. The length of this miniature piezo electric motor is:
A. 8.0 cm B. 7.98 mm C. 7.99 m D. 8.0 mm
20. How many significant figures are in the measurement 1.3000 meters?
A. five B. four C. three D. two
Psychology 1102 exam review
Written By Unknown on Friday, July 26, 2013 | 8:46 AM
Answer for Q1
Psychological Science considered as a purely objective, experimental branch of natural science with the theoretical goal of predicting and controlling behavior.
2) Define psychology and provide a rationale for why the answer to question #1 is so important.
Answer for Q2
Psychology is science of mind, of mental state, and processes, and scientific approach is so important because of unpredictable behavior and state of mind.
3) In 1-2 sentences describe why it’s important to study the brain in psychology.
Answer for Q3
It is important to study the brain because every parts of the brain has functions, and it relates to every behaviors that supported by specific brain activations.
4) What is the field that presumes it can study the supernatural?
Answer for Q4
Parapsychology
5) Technically, Psychology is a branch of what other scientific discipline?
Answer for Q5
Cognitive science
6) What is the difference between a state and a trait? Give an example.
Answer for Q6
a) Mood state is a temporary way of being.
b) Trait is a stable or relatively unchanging characteristic.
Example: I am excited today. (Relates my current mood)
7) Describe the difference between top-down and bottom-up sensory processing. Give an example.
Answer for Q7
a) Top-down processing: Sensory information is interpreted in light of existing knowledge.
Example: When we read, we begin to interpret the words and sentences based on our previous knowledge.
b) Bottom-up processing: The brain takes in individual elements of a particular stimulus, and then combines those elements into a "unified perception".
Example: When we read, our brain takes in each letter individually rather than the entire word. The brain then unifies those letters to obtain the word they're in.
8) (a) Why is the “need to belong” motivation so strong in humans? (b) What happens to people who do not belong or are excluded from a group? (c) Give an example of an animal for which you would not hypothesize the “need to belong” motivation would exist?
Answer for Section A, Q8
Strong desire: caring, affectionate bonds.
Answer for Section B, Q8
Rude people do not belong to any group
Answer for Section C, Q8
A dog can be an animal which I would not hypothesize, but once I start to belong with, I would be adjusting because of its nature is a so loving.
9) What is g?
Answer for Q9
General intelligence
10) What part of the brain drives the fight/flight/freeze response?
Answer for Q10
The limbic system
11) Describe the difference between conscious and unconscious processing. What did Freud mean by the unconscious? How did Freud think the unconscious affected behavior?
Answer for Q11
Section A, Q11. Conscious: Knowing and perceiving; and Unconscious: Not knowing and perceiving.
Section B, Q11. Freud describes the unconscious as the reservoir of all the thoughts that lie outside of awareness.
Section C, Q11. Freud thinks that the unconscious keeps driving our behavior and experience, even though we are unaware of these basic influences.
12) Sexual behavior is driven by what underlying process/motivation?
Answer for Q12
In many ways, emotion motivates the sexual behavior. Having sex may be a means of expressing feelings towards a partner as well as a way of deriving emotional satisfaction.
13) What is a scientific Theory? Rank order the following scientific theories and give a brief description of why you ranked them the way you did:
a. Gravitational Field Theory
b. Multiple Intelligences theory
c. Evolutionary theory
Answer for Q13
A scientific theory is based on careful examination of facts.
1. Evolutionary theory
2. Gravitational Field Theory
3. Multiple Intelligences theory
After began setting up the universal, physics play in our life and every species and human starts the evolution, scientist proved that any two objects, no matter their mass, exert gravitational force toward one another, and finally, multiple intelligences provides a solid foundation upon which to identify, value and develop students' abilities.
14) List the 6 basic principles of critical thinking.
Answer for Q14
1. Extraordinary claims
2. Falsifiability
3. Occam’s Razor
4. Replicability
5. Ruling out Rival Hypotheses
6. Correlation vs Causation
15) Describe the difference between naturalistic observation, correlational study, and experiment.
Answer for Q15
Naturalistic observation: carefully observed in natural setting.
Correlational study: measuring the relation between two variables.
Experiment: a study in which the investigator manipulates at least one variable.
16) Design an experiment to test social behavior in humans.
Answer for Q16
First of all, we need a controlled environment where outside influences cannot interrupt our test and a soundproof room where we could place a person in the room and introduce something to see the reaction, like food.
17) Give an example of social facilitation that happens in your life.
Answer for Q17
I would love to help people and make them happy.
18) Describe the features of the Implicit Associations Test and in your own words discuss the importance of this test in studying prejudice and discrimination.
Answer for Q18
Many people who act like genuine, but they are implicitly faking and unable to pure hearted person. I think this test at least increases some genuine behavior or people.
19) With respect to the bystander effect what is the most parsimonious explanation? (HINT: it does not come from social psychology)
Answer for Q19
Diffuse of bystander, if someone in the street pertaining or real to ill, but no one cares him and this makes me feel so bad.
20) What is the most interesting thing that you learned in this class?
Answer for Q20
I learned the ideas to see the world in different perspective by feeling of awareness within and sense of activating every parts of brain.
BONUS QUESTION:
Think of a personal experience in your life; describe that experience. Given what you’ve learned about psychology and the brain how would you change the way you approached that experience now?
After learning psychology, I have gained tremendous amount of senses within and gained tricks of controlling of negative and positive emotions. Moreover, learning of dealing with negative emotions, stress, and anxieties put me to the next level of thinking process.
Subscribe to:
Posts (Atom)





