Write a program that takes a string and integer as input, and outputs a sentence using those items as below. The program repeats until the input string is quit 0. Ex: If the input is: apples 5 shoes 2 quit 0 the output is: Eating 5 apples a day keeps
Q: Write a Java program to take input a string from user and print all characters at odd index in one…
A: String indexing starts from 0 So, the characters at odd indices are 1,3,5,..... and the characters…
Q: Write a program which separates sentence, “there is a cat", into words as shown below. Output there…
A: PROGRAM INTRODUCTION: Use the required libraries and include them. Start the definition of the main…
Q: Write a java program that reads in three strings and sorts them alphabetically. You can ask to enter…
A: In Java, we have s1.compareTo(s2) method which compares the given strings. and on the basis of…
Q: Write a program in java to count the number of vowels in string. Attach the output also.
A: Program Approach - Import the java libraries as per code requirement. Define the method named…
Q: Write a Java program to print all combinations of phreses formed by picking words from each of the…
A: The Program is written in java import java.util.ArrayList; class Main { public static void…
Q: Write a Python program to find the first appearance of the substring 'too' and 'good' from a given…
A: Task :- Write a python code to replace a substring with another for given condition. We need to…
Q: Write a Java program to take a non-empty string like "Eat" print a string like "EEaEat".
A: This program can be done by using strings concept in Java. Input: "Eat" Output: "EEaEat"
Q: Write a Java program using a for loop or a while loop that reads a word and prints the word in…
A: Given: Write a Java program using a for loop or a while loop that reads a word and prints the word…
Q: Write a java program to take a string from user and print inside it in double quote
A: Required:- Write a java program to take a string from the user and print it inside it in double…
Q: JAVA Write a Java program to compare two strings lexicographically and print before if string a is…
A: We have to print before if string a is before b and print same if they are equal
Q: Write a Java program Instructions: Convert a number to a string, the contents of which depend on…
A: Step 1 : Start Step 2 : Take user input of the number Step 3 : Using modular division checking if…
Q: Write a program that reads in a string containing three words separated by commasand then outputs…
A: We have to write a program that can read in a string containing three words separated by commasand…
Q: Write a Java program which reads a String composed of one or many words and prints out the number of…
A: import java.util.*;public class Main{ public static void main(String[] args) { String s; int…
Q: Write a program that reads a five-letter word from the user and produces all possible three letter…
A: Write a program that reads a five-letter word from the user and produces allpossible three letter…
Q: Write a Java program to take 2 strings from user a and b, return a string of the form…
A: With the shorter string on the outside and the longer string on the inside. The strings will not be…
Q: Write a Java program to get a sub string of a given string
A: //Program public class substringexample { public static void main(String args[]) { String…
Q: Write a Java application which prompts the user for enter a String, counts the number of vowels (a,…
A: In this question, we are asked to write a java program in such way that user enter a string are…
Q: ample Input: Text string: You will always have my love, my love, for the love I love is as lovely as…
A: import java.io.*;import java.util.Scanner; class Main { public static int countOccurrences(String…
Q: Solve in java Find the index of a string within a hex encoded string. You will be given a string…
A: Algorithm - Take one string as input. Now use the below logic String decoded =…
Q: Write a program that accepts a string input and outputs the number of characters in the string and…
A:
Q: Write a program in java for the below given problem statement: Given an integer n, using phone…
A: Coded using Java.
Q: Write a JAVA program that reads integers, finds the largest of them, and counts its occurrence.…
A: Ans:) In this java program the steps that need to be followed are: Define the scanner for input.…
Q: Write a java program that count the number of letters in a String and find the first occurrence of…
A: replaceAll() replaces all occurrences indexOf() finds the first occurrence of character at given…
Q: Write a Java program that takes the user to provide a single character from the alphabet. Print…
A: I give the code in Java along with output and code screenshot
Q: Write a program whose input is a string which contains a character and a phrase, and whose output…
A: We need to write a python program to print the number of times the particular character appears in…
Q: Write a program that reads a list of scores and then assigns gradesbased on the following scheme:The…
A: Given: Write a program that reads a list of scores and then assigns gradesbased on the following…
Q: Java Receive a string of comma separated integers from user input. Find the largest integer. For…
A: Main.java import java.io.*;import java.util.*;class Main{ public static void main(String args[])…
Q: Write a program that gets a string from the user and maps the capital letters into small letters,…
A: Since no programming language is mentioned, therefore, program is written in Python programming…
Q: 2. Using Java notation, suppose A is the alphabet { 'a','b','c' } List the labels of all strings in…
A: 2. The solution for the parts are as follows: a. "" It is in A*. b. "aa" It is in A*. c. "bb" It is…
Q: Write a program that takes in a line of text as input, and outputs that line of text in reverse. The…
A:
Q: Solve in java Find the index of a string within a hex encoded string. You will be given a string…
A: Algorithm - Take one string as input. Now use the below logic String decoded =…
Q: Write a Java program to test if a given string contains only digits and special symbols…
A: import java.util.Scanner; public class Check{ public static void main(String []args) {…
Q: Write a python program that takes a string as an input from the user and checks if there are any…
A: Start input # vowels stringvowel="aeiou" if any vowel encountered and there exists two more…
Q: Write a Java program to take a string and an int n, print a string made of n repetitions of the last…
A: Solution: Java code: import java.util.*; public class Test { public static void…
Q: Write a program that reads the full name of a student; and then prints it in the form: last first…
A: C++ Program: # include <iostream># include <string>using namespace std; int main(){…
Q: Write a JAVA program that takes input a single line sentence and displays the second word of the…
A: Write a JAVA program that takes input a single line sentence and displays the second word of the…
Q: Write a program that takes in any string (with or without spaces) and outputs the numbers each…
A: According to the Question below the Solution: Output:
Q: Write a java program that enables the user to enter a string and an index,then cuts the letter in…
A: A part of String is called substring.
Q: Write a program that takes in any string (with or without spaces) and outputs the numbers each…
A: ANSWER:-
Q: Write a Java program to take a string, print a string where for every char in the original, there…
A: Required: Write a Java program to take a string, print a string where for every char in the…
Q: Write a program in c++that reads a positive integer n, and prints the first n even numbers. For…
A:
Q: Write a Java program that reads a string from the user and prints it one character per line.
A: A java string is a sequence of characters that exist as an object of the class java.lang.
Q: Write a program in JAVA language to take input two strings str1, str2 from the user and form a new…
A: Write a program in JAVA language to take input two strings str1, str2 from the user and form a new…
Q: Write a Java program to take a string and a non-negative int n, þrint a larger string that is n…
A: Required:- Write a Java program to take a string and a non-negative int n, print a larger string…
Q: Write a program that reads a list of words. Then, the program outputs those words and their…
A: Program:#print the statementprint ("Enter the input:") #get the input and store it a…
Q: Task 14 An anagram is a play on words created by rearranging the letters of the original word to…
A: PROGRAM CODE: def check(s1, s2): // start the definition of the function to…
Q: Write a Java program that uses two nested for loops and the modulus operator (%) to detect and print…
A: 1) Below is Java program that uses two nested for loops and the modulus operator (%) to detect and…
Q: Write a program in java to take a string from user and make it to a palindrome. Don't copy from…
A: Requirements:- Write a program in java to take a string from the user and make it to a palindrome.…
Q: Write a java program that takes a string as input from the user and finds out if the string is a…
A: import java.util.*; public class Main { public static void main(String args[]) { String a, b = “”;…
Write a program that takes a string and integer as input, and outputs a sentence using those items as below. The program repeats until the input string is quit 0.
Ex: If the input is:
apples 5 shoes 2 quit 0
the output is:
Eating 5 apples a day keeps the doctor away. Eating 2 shoes a day keeps the doctor away.
import java.util.Scanner;
public class LabProgram {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
String some_string;
int some_int;
some_string = scnr.next();
some_int = scnr.nextInt();
if (some_int != 0){
System.out.println("Eating " + some_int + " " + some_string + " a day keeps the doctor away.");
}
}
}
My program wil online output the first input but not the next. What am I missing???
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images
- (Modify) a. Modify the program you wrote for Exercise 7 to provide the mass of a person as an output, given his or her weight as an input to the program. Use your program to determine the mass of a person who weighs 140 lbf on Earth. b. Modify the program written for Exercise 7a to also output the person’s weight on Mars and the moon. The pull of gravity on Mars is 12.54ft/sec2=3.728m/s2,andonthemoonis5.33ft/sec2=1.625m/s2.User Defined Function: Return Value Create a JAVA program compute the area of the following polygons and circle. Area of square given the side. Area of rectangle given the length and width. Area of triangle given the base and height. Area of circle given the radius. EXPECTED OUTPUT:python solution please Task 1Description let's consider a case when you need a lot of coffee. Maybe you're hosting a party with a lot of guests! In these circumstances, it's better to make preparations in advance.So, we will ask a user to enter the desired amount of coffee, in cups. Given this, you can adjust the program by calculating how much water, coffee, and milk are necessary to make the specified amount of coffee.Of course, all this coffee is not needed right now, so at this stage, the coffee machine doesn't actually make any coffee yet. ObjectivesLet's break the task into several steps:First, read the numbers of coffee drinks from the input.Figure out how much of each ingredient the machine will need. Note that one cup of coffee made on this coffee machine contains 200 ml of water, 50 ml of milk, and 15 g of coffee beans.Output the required ingredient amounts back to the user. ExamplesThe greater-than symbol followed by space (> ) represents the user input. Notice that…
- Dealing With Months by CodeChum Admin We're done dealing with days. It's time to step up and now deal with months! Instructions: 1. In the code editor, you are provided with a code in the main() which has 12 cout's. Each cout prints a month with its corresponding value. For this program, January is 1, February is 2, March is 3, and so on. When you run the initial code, you will encounter errors because these month names that have been printed don't exist yet. 2. Your task is to create an enum data type which contains these month names as values so that when we run the code, there will be no more error. 3. Do not edit anything in the main(). Output January.= 1 February = 2 March:= 3 April-=-4 May--5 June:=-6 July =-7 August.=-8 September ·=-9 October:= 10 November.=11 December.= 12Write in Assembly Language Programming show code and submit output screenshot 3) A bag of cookies holds 30 cookies. The calorie information on the bag claims that there are 10 “servings” in the bag and that a serving equals 240 calories. Write a program that asks the user to input how many cookies they actually ate and then reports how many total calories were consumed.can someone help me with this code in python 1a. Enter x: 5 x doubled is: 10 Students often incorrectly create a program that outputs the 5. Instead, the program should only output the output parts: Enter x: x doubled is: 10 The instructor's example is showing both the output of the program, AND the user's input to that program, assuming the program is developed in an environment where a user is interacting with a program. But the program itself doesn't output the 5 (or the newline following the 5, which occurs when the user types 5 and presses enter). Also, if the instructor configured the test cases to observe whitespace, then according to the above example, the program should output a newline after Enter x: (and possibly after the 10, if the instructor's test case expects that). 1B. For each of the following steps, end the program's output with a newline. (1) Write a program that outputs the following. Hello world! (2) Update to output the following. Hello world! How are…
- i. Find the loop invariant for the program code below. void main() { int y = 1, x = 0; while (x < 4) { y = y * z; x = x + 1; }Need Python code: Mad Libs are activities that have a person provide various words, which are then used to complete a short story in unexpected (and hopefully funny) ways. Write a program that takes a string and an integer as input, and outputs a sentence using the input values as shown in the example below. The program repeats until the input string is quit and disregards the integer input that follows. Ex: If the input is: apples 5 shoes 2 quit 0 the output is: Eating 5 apples a day keeps the doctor away. Eating 2 shoes a day keeps the doctor away. ThanksPhone Company charges for phone calls by distance (miles) and length of time (minutes) The cost of a call (in dollars) is calculated as 0.15 (length of time + 0.02 * distance). Design, write, test, and run a Python program using IDLE's script mode (NOT interactive mode). The program should calculate the cost of each of four phone calls and the total cost of all four phone calls. The program should be designed to request the times and distances from the program's user through the use of the keyboard. What is a user? The program's user is you when you are testing and running the program. The instructor will be the user when the program is checked. The output of your program should display the time, distance, and cost of each call. In addition, it should display the total cost of all four phone calls. Please do fast fastt...
- Q5: Nb of correct programs Feedback Inadequate assignment half correct assignment Acceptable attempt 3 Wonderful attempt 4 Brilliant attempt Write the Java program that reads the number of correctly solved programs and displays the adequate feedback. Note: Use if-else 2.algorithm, pseudocode and flowchart of this question. Sarah Cruz has been working for COMPUTER Z Company for four years. Last year, Sarah received a 5% raise, which brought her current monthly pay to 25,000.00 pesos. Sarah is scheduled to receive a 4% raise next month. She wants to write a program that will display, on the computer screen, the amount of her new monthly pay.Exercise 6: Write a program that reads from the user three pieces of information: The current population of a country, the annual birth rate of the country, and its annual death rate. The program should then calculate the expected population for the following year and display the results as shown in Figure 6. Please note that population for the following year is calculated as sum of the current population, and the number of births by the end of the year minus the number of deaths by the end of the same year. Name your program Lab3_Id_ex6.py, where Id is your university Id. Include the design of your solution as comments at the beginning of your program. Test your solution with different input data. Please enter the current population of the country: 1800000 Please enter the birth rate: 0.017 Please enter the death rate: 0.005 Current Population Number of Number of Deaths Next Year Births Population 1800000 30600 9000 1821600 Figure 6: Sample Run