Write a program that asks the user to enter a person’s age. The program should display a message indicating whether the person is an infant, a child, a teenager, or an adult.
Following are the guidelines:
• If the person is 1 year old or less, he or she is an infant.
• If the person is older than 1 year, but younger than 13 years, he or she is a child.
• If the person is at least 13 years old, but less than 20 years old, he or she is a teenager.
• If the person is at least 20 years old, he or she is an adult.
Python
Write a program that asks the user for two integers that will correspond to the numbering of the first and last lines, then a third integer that will correspond to the number of z before “zigzag” (not counting the first “z” of zigzag), then finally that displays a zig-zag following the following pattern:
Exemple 1:
Start Number: * user type 3 *
End number: * user type 10 *
Number of z: * user type 5 *
zzzzzzigzag 3
4 zzzzzzigzag
zzzzzzigzag 5
6 zzzzzzigzag
zzzzzzigzag 7
8 zzzzzzigzag
zzzzzzigzag 9
10 zzzzzzigzag
(Even integers must be left-zigzag and odd integers must be right.)
Example 2:
Start number:* user type -2 *
End Number:* user type 4 *
Number of z: * user type 3 *
-2 zzzzigzag
zzzzigzag -1
0 zzzzigzag
zzzzigzag 1
2 zzzzigzag
zzzzigzag 3
4 zzzzigzag
Example 3:
Start Number:* user type 5 *
End number:* user type 0 *
Number of z: * user type 10 *
(Nothing is displayed because 5>0)
Please provide Java source code for following project with proper comments.
Write a program that asks the user to enter a distance in meters. The program will then pre-sent the following menu of selections:
Convert to kilometers
Convert to inches
Convert to feet
Quit the program
The program will convert the distance to kilometers, inches, or feet, depending on the user’s selection. Here are the specific requirements:
Write a void method named showKilometers, which accepts the number of meters as an argument. The method should display the argument converted to kilometers. Convert the meters to kilometers using the following formula:
kilometers = meters * 0.001
Write a void method named showInches, which accepts the number of meters as an argument. The method should display the argument converted to inches. Convert the meters to inches using the following formula:
inches = meters * 39.37
Write a void method named showFeet, which accepts the number of meters as an argument. The method should display the argument converted to feet. Convert the meters to feet using the following formula:
feet = meters * 3.281
Write a void method named menu that displays the menu of selections. This method should not accept any arguments.
The program should continue to display the menu until the user enters 4 to quit the program.
The program should not accept negative numbers for the distance in meters.
If the user selects an invalid choice from the menu, the program should display an error message.
Here is an example session with the program, using console input. The user’s input is shown in bold.
Enter a distance in meters: 500 [Enter]
1. Convert to kilometers
2. Convert to inches
3. Convert to feet
4. Quit the program Enter your choice: 1 [Enter]
500 meters is 0.5 kilometers.
1. Convert to kilometers
2. Convert to inches
3. Convert to feet
4. Quit the program
Enter your choice: 3 [Enter]
500 meters is 1640.5 feet.
1. Convert to kilometers
2. Convert to inches
3. Convert to feet
4. Quit the program
Enter your choice: 4 [Enter]
Bye!
Do not write the code in multiple programs. Both methods (a and b) should be written in 1 program.
Example 1:
Input two numbers: 6 2
Array is [6, 5, 4, 3, 2]
Example 2:
Input two numbers: 4 8
Array is [4, 5, 6, 7, 8]
public static void main(String[] args) {
char a = (char) 65;
System.out.print(a);
}
public static char changeCase(char c) {
// ASCII
// a <==> 97 b = 98,
// A 65 B 66
// ‘a’ – (97-65) = ‘A’
// ‘A’ + (97-65) = ‘a’
return ‘a’;
}
}
Write a program that asks the user for the name of a file, and an integer number. The program should display the first several lines of the file on the screen, and the number of lines should be equal to the integer entered by the user. If the number of lines the file has is less than the integer entered by the user, then the entire file should be displayed, with a message indicating the entire file has been displayed.
When evaluating the peer submissions, please consider two cases to verify the program, with one case where the file has enough lines, and one case where the file does not have enough lines.
Please submit your solution to the lab instructor once you have your program working. Your lab instructor will tell you how (s)he would like you to turn it in.
Failure to submit will result in a zero.
(Don’t forget to consider the situation of a=b, a<b, and a>b.)
Example 1:
Input two numbers: 6 2
Array is [6, 5, 4, 3, 2]
Example 2:
Input two numbers: 4 8
Array is [4, 5, 6, 7, 8]
(Do not use Math library to get the average.)
Please attach your screenshot below to each question a and b.
JAVA PROGRAM
(Don’t forget to consider the situation of a=b, a<b, and a>b.)
Example 1:
Input two numbers: 6 2
Array is [6, 5, 4, 3, 2]
Example 2:
Input two numbers: 4 8
Array is [4, 5, 6, 7, 8]
(Do not use Math library to get the average.)
// Add your code below
public static void main(String[] args) {
}
public static boolean isVowel(char c) {
}
}
Program 1:
Write a program that asks the user to input a sentence and then outputs the sentence back with the case of every character reversed.
So for example: “CaTs RuLe!” would be given back as “cAtS rUlE!” .
Spaces and punctuation should be left in place.
You can use the Character class static functions to test the case of each letter.
You do not need to place any code in static methods (besides the main method), you do not need to worry about try/catch blocks, and you do not need to make the program run more than once.
in java
. Write a program that asks the user for the name of a file, and an integer number. The program should display the first several lines of the file on the screen, and the number of lines should be equal to the integer entered by the user. If the number of lines the file has is less than the integer entered by the user, then the entire file should be displayed, with a message indicating the entire file has been displayed.
When evaluating the peer submissions, please consider two cases to verify the program, with one case where the file has enough lines, and one case where the file does not have enough lines. This question belongs to c++.
The problem is the following :
Write a program that asks the user for the name of a file. The program should display the contents of the file with each line preceded with a line number followed by a colon. The line numbering should start at 1.
Please edit this scanner to JOptionPane. I don’t really know how to do that.
//Java Program by Yuiri Fujita and Darrick Drewry 10/30/2020
import java.util.Scanner;
import java.io.*;
public class LineNumbers {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
String userFileName;
System.out.println(“Please enter the name of the file.( Enter LineNumbers.txt)”);
userFileName = input.nextLine();
File file = new File( userFileName);
while( !file.exists() ){
System.out.println( userFileName + ” does not exist. Please enter a different file name”);
userFileName = input.nextLine();
file = new File ( userFileName);
}
Scanner fileToScan = new Scanner (file);
String line;
int counter = 0;
while (fileToScan.hasNext()){
counter += 1;
line = fileToScan.nextLine();
System.out.println(counter + “: ” + line);
}
}
}
Time Calculator
Write a program that asks the user to enter a number of seconds.
-There are 60 seconds in a minute. If the number of seconds entered by the user is greater than or equal to 60, the program should display the number of minutes and leftover seconds in that many seconds.
-There are 3,600 seconds in an hour. If the number of seconds entered by the user is greater than or equal to 3,600, the program should display the number of hours, minutes, and leftover seconds in that many seconds.
-There are 86,400 seconds in a day. If the number of seconds entered by the user is greater than or equal to 86,400, the program should display the number of days, hours, minutes, and leftover seconds in that many seconds.
Write a program that asks the user for the names of two files. The first file should be opened
for reading and the second file should be opened for writing. The program should read
the contents of the first file, change all characters to uppercase, and store the results in the
second file. The second file will be a copy of the first file, except that all the characters will
be uppercase. Use Notepad or another text editor to create a simple file that can be used
to test the program.
can you plz make it util.scanner form and can you make it so i can copy and past it plz
thank you in advance
can you plz make it util.scanner form and can you make it so i can copy and past it plz
thank you in advanced
Write a program that asks the user to enter today’s sales for five stores. The program should
display a bar chart comparing each store’s sales. Create each bar in the bar chart by displaying
a row of asterisks. Each asterisk should represent $100 of sales. Here is an example of
the program’s output:
Enter today’s sales for store 1: 1000 [Enter]
Enter today’s sales for store 2: 1200 [Enter]
Enter today’s sales for store 3: 1800 [Enter]
Enter today’s sales for store 4: 800 [Enter]
Enter today’s sales for store 5: 1900 [Enter]
SALES BAR CHART
Store 1: **********
Store 2: ************
Store 3: ******************
Store 4: ********
Store 5: *******************
Q7. Write a program that asks the user for the name of a file, and an integer number. The program should display the first several lines of the file on the screen, and the number of lines should be equal to the integer entered by the user. If the number of lines the file has is less than the integer entered by the user, then the entire file should be displayed, with a message indicating the entire file has been displayed.
When evaluating the peer submissions, please consider two cases to verify the program, with one case where the file has enough lines, and one case where the file does not have enough lines.
PS: Using C++
Write a program that asks the user to enter an item’s wholesale cost and its markup percentage. It should then display the retail price for the item. For example: • If the wholesale cost is £3.00 and the markup percentage is 100%, the retail price will be £6.00 • If the wholesale cost is £5.00 and the markup percentage is 50%, the retail price will be £7.50. The calculation should be done by a method called CalculateRetailPrice in a class called RetailPricing. The method CalculateRetailPrice should the wholesale cost and markup percentage as arguments and returns the retail price. require to be in c#
Write a program that asks the user to enter an amount of money in the format of dollars and remaining cents. The program should calculate and print the minimum number of coins (quarters, dimes, nickels and pennies) that are equivalent to the given amount.
Hint: In order to find the minimum number of coins, first find the maximum number of quarters that fit in the given amount of money, then find the maximum number of dimes that fit in the remaining amount, and so on.
File Name
coins.py
Score
There are five tests each worth 2 points
For example, an execution should look like this:
Please enter the amount of money to convert:
# of dollars: 2
# of cents: 37
The coins are 9 quarters, 1 dimes, 0 nickels and 2 pennies
these program might be in python
Write a program that asks the user for two integers and a character, ‘A’, ‘S’, or ‘M’. Call one of three functions that adds, substracts, or multiplies the user’s integers, based on the character input.
This is what I have so far but I cant figure out how to link the character data A, M, or S to the specific funtions.
#include<iostream>
using namespace std;
void main()
{
int a, b;
char c;
int result=0;
cout << ” Please enter first integer: “;
cin>> a;
cout << ” Please enter second integer: “;
cin>> b;
cout << “nnn(A) Additionnnn(M) Multiplicationnnn(S) SubstractionnnnPlease enter a character input: “;
cin>> c;
while (c!=’A’ && c!=’a’ && c!=’M’ && c!=’m’ && c!=’S’ && c!=’s’)
{
cout<<“Invalid selection.nnYou must enter a valid selection A, M, or S.nn”<<endl;
cout<<“Please enter a character input: “;
cin>>c;
cout<<endl;
}//end while
if (c == ‘A’ || c == ‘a’)
{
}
}
int resultAdd(int num1, int num2)
{
int result;
result = num1 + num2;
cout<<“The sum of two integers is: ” <<result<<endl;
return result;
}
int resultMult(int num1, int num2)
{
int result;
result = num1 * num2;
cout<<“The multiplication of two integers is: ” <<result<<endl;
return result;
}
int resultSub(int num1, int num2)
{
int result;
result = num1 – num2;
cout<<“The difference between two integers is: ” <<result<<endl;
return result;
}
Write a program that asks the user for two integers and a character, ‘A’, ‘S’, or ‘M’. Call one of three functions that adds, substracts, or multiplies the user’s integers, based on the character input.
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more
Recent Comments