//1.
import java.util.Scanner;
public class {
public static void main(String[] args) {
int n1, n2, swap,num, oddsum, sumsq;
Scanner s = new Scanner(System.in);
char c;
System.out.println("Enter First Number: ");
n1 = s.nextInt();
System.out.println("Enter Second Number: ");
n2 = s.nextInt();
s.close();
if(n1<0)
{
n1=-n1;
}
else if(n2<0)
{
n2=-n2;
}
if (n1>n2)
{
swap=n1;
n1=n2;
n2=swap;
}
oddsum=0;
num=n1;
sumsq=0;
while (num >= n1 && num <= n2){
if (num % 2 != 0)
{
oddsum = oddsum + num; //sum of odd
sumsq=sumsq+num*num;
}
num++;
}
System.out.println("Sum of odd integere is "+ oddsum);
System.out.println("Sum of SQUARES OF odd integers is "+ sumsq);
c='a';
System.out.println("Lowercase letters are ");
while(c<='z')
{
System.out.printf("%s ", c);
c++;
}
}
}
// 2
import java.util.Scanner;
public class {
public static void main(String[] args) {
float g,m; //g for gallons and m for miles
float avg,sum=0,n=0,mpg;
Scanner s = new Scanner(System.in);
while(0)
{
System.out.println("Enter the gallons used(-1 to end): ");
g = s.nextFloat();
if (g==-1)
break;
System.out.println("Enter the miles drives: ");
m = s.nextFloat();
mpg=g/m;
System.out.println("The miles per gallon for this tank is: "+mpg);
n++;
sum=sum+mpg;
}
avg-sum/n;
System.out.println("The overall average miles/gallon was "+avg;);
}
}
//3
import java.util.Scanner;
public class {
public static void main(String[] args) {
int A, B;
int A1, B1;
float ga,gb;
Scanner s = new Scanner(System.in);
System.out.println("Enter current student numbers of school A: ");
A = s.nextInt();
System.out.println("Enter current student numbers of school B: ");
B = s.nextInt();
System.out.println("Enter the growth rate of school A(percentage): ");
ga = s.nextFloat();
System.out.println("Enter the growth rate of school B(percentage): ");
gb = s.nextFloat();
a1=a;
b1=b;
for(int x=0;a1<b1;x++)
{
a1=a1+a1*ga;
b1=b1+b1*ga;
}
System.out.println("After"+x + "years the students numbersof A will be greater than or equal to B");
System.out.println("After"+x + "years the students numbers of A"+a1);
System.out.println("After"+x + "years the students numbers of B"+b1);
}
}
//4
import java.util.Scanner;
public class {
public static void main(String[] args) {
float gal,sum=0;
int x;
Scanner s = new Scanner(System.in);
while(x!=0)
{
System.out.println("87 - Regular $2.45");
System.out.println("89 - Plus $2.89");
System.out.println("93 - Premium $3.09");
System.out.println("O - exit");
x=s.nextint();
switch(x)
{case 87 :
System.out.println("Enter the gallons used");
gal=s.nextFloat();
if(gal<=0)
System.out.println("Gallons used must be greater than 0, try again");
else
{
System.out.println("the price is"+gal*2.45);
sum=sum+gal;
}
break;
case 89 :
System.out.println("Enter the gallons used");
gal=s.nextFloat();
if(gal<=0)
System.out.println("Gallons used must be greater than 0, try again");
else
{
System.out.println("the price is"+gal*2.89);
sum=sum+gal;
}
break;
case 93 :
System.out.println("Enter the gallons used");
gal=s.nextFloat();
if(gal<=0)
System.out.println("Gallons used must be greater than 0, try again");
else
{
System.out.println("the price is"+gal*3.09);
sum=sum+gal;
}
break;
case 0:
System.out.println("Total sales is"+sum);
break;
default:
System.out.println("invalid response. Try agian");
}
}
}
}
Use a java program that does the following: . (10 points) Write a program as follows...
Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several tankfuls of gasoline by recording miles driven and gallons used for each tankful. Develop a C++ program that will input the miles driven and gallons used for each tankful. The program should calculate and display the miles per gallon obtained for each tankful. After processing all input information, the program should calculate and print the combined miles per gallon obtained for all tankfuls....
Drivers are concerned with the mileage their automobiles get. One driver has kept track of several tankfuls of gasoline by recording the miles driven and gallons used for each tankful. Develop a C# app that will input the miles driven and gallons used (both as integers) for each tankful. The app should calculate and display the miles per gallon obtained for each tankful and display the combined miles per gallon obtained for all tankfuls up to this point. All averaging...
Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several tankful of gasoline by recording miles driven and gallons used for each tankful. Develop a C++ program that inputs the miles driven and gallons used for each tankful. The program should calculate and display the miles per gallon obtained for each tankful and print the combined miles per gallon obtained for all tankfuls up to this point.
7.11 Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several tankfuls of gasoline by recording the number of miles driven and the number of gallons used for each tankful. Develop a script that will take as input the miles driven and gallons used (both as integers) for each tankful. The script should calculate and output HTML5 text that displays the number of miles per gallon obtained for each tankful and the combined...
Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several tanks of gasoline by recording miles driven and gallons used for each tank. Develop a program using a while loop that will input the miles driven and the gallons used for each tank. The program should calculate and display the miles per gallon obtained for each tank. After processing all input information, the program should calculate and print the overall miles per gallon...
C++ please Question 4: 125 points] Write and test a program that reads two positive integers nl and n2 with n2 > nl. The program then calculates the sum of the prime numbers, using is prime () function developed above, between nl and n2 (inclusive) A Sample input Enter values for nl and n2 (nl<n2): 3 9 Output: Thé Sum of prime numbers between 3 and 9 (inclusive) is 15
Write program PSEUDOCODE that prompts the user for their name and then will compute a car's miles per gallon given input of miles driven and gallons of gas used. It should also convert those given numbers into metric and show kilometers driven, liters used, and kilometers per liter. All with well formatted output. Submit: C++ Programming Warm-Up Exercise PSEUDOCODE for the algorithm that compute's a car's miles per gallon given input of miles and convert these numbers into metric and...
write the program in VBA b. Write a program that uses a For loop to perform the following steps: a. Prompt the user to input two integers: firstNum and secondNum(firstNum must be less than secondNum). b. Output all odd numbers between firstNum and secondNum. c. Output the sum of all odd numbers between firstNum and secondNum. d. Output all even numbers between firstNum and second Num. e. Output the sum of all even numbers between firstNum and secondNum.
I need trying to figure out how I can make create a code in Python with this exercise for I am having trouble doing so. Miles Per Gallon Calculator Write a GUI program that calculates a car's gas mileage. The program's window should have Entry widgets that let the user enter the number of gallons of gas the car holds, and the number of miles it can be driven on a full tank. When a Calculate MPG button is clicked,...
java program: Write a program which displays the following list on the screen and asks the user to enter either 1 or 2 and perform one of the operations based on the user’s input. If the user enters any other character other than 1 or 2 then display “wrong choice”. LIST OF OPERATIONS 1. Buzz Number 2. Consecutive Odd numbers Note: A BUZZ number is a number which either ends with 7 or is divisible by 7. Sample input 27...