


//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...
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 tankful up to this point. (Use the five-step problem solving methodology)...
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
Programming Language is Java Lab 1: Programming Exercises Input/Process/Output 1) Run the Numbers. Write a program with two input values. The program should display the sum, difference, quotient, product, and average of the two numbers. 2) Jake’s Problem. Jake has a car with an 8-gallon fuel tank. Jake fills his tank with gas and drives 60 miles to a friend’s house. When he gets to his friend’s house, he has 6 gallons left in his fuel tank. Write a program...
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 a Java program to prompt for inputting an integer N, then enter N integers (a loop is needed), print the numbers user entered, and the amount of even and odd numbers (zero is even number). (1) Prompt for the user to input an integer and output the integer. (1 pts) Enter an integer: You entered: 5 (2) Prompt for the user to input N integers, output the numbers entered and the amount of even and odd numbers (9 pts)...