Question
using the code and the video below demo create an app that locks and works exactly as shown https://watch.screencastify.com/v/JQ5sKfgovEWzDO3Y1Elf package com.example.labactivity2; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle;
using the code and the video below demo create an app that locks and works exactly as shown
https://watch.screencastify.com/v/JQ5sKfgovEWzDO3Y1Elf
package com.example.labactivity2;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast;
public class MainActivity extends AppCompatActivity { EditText from, to, value; Button convert; TextView result; double celsius, farenheit ;
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); from=findViewById(R.id.edFrom); to=findViewById(R.id.edTo); convert=findViewById(R.id.btnConvert); value=findViewById(R.id.edValue); result=findViewById(R.id.tvResult); convert.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if((from.getText().toString().trim().equalsIgnoreCase("Celsius"))&&(to.getText().toString().trim().equalsIgnoreCase("Celsius"))||(from.getText().toString().trim().equalsIgnoreCase("farenheit"))&&(to.getText().toString().trim().equalsIgnoreCase("farenheit"))) { from.setError("both cannot be same"); to.setError("both cannot be same"); }
else if((from.getText().toString().trim().equalsIgnoreCase("Celsius"))&&(to.getText().toString().trim().equalsIgnoreCase("Farenheit"))){
celsius=Double.parseDouble(value.getText().toString());
farenheit=(celsius*1.8)+32; String s1=String.format("%.1f",farenheit); result.setText(s1+" F"); from.setText(""); to.setText(""); value.setText(""); } else if((from.getText().toString().trim().equalsIgnoreCase("Farenheit"))&&(to.getText().toString().trim().equalsIgnoreCase("celsius"))) {
farenheit=Double.parseDouble(value.getText().toString());
celsius=(5*(farenheit-32))/9; String s1=String.format("%.1f",celsius); result.setText(s1+" C"); }
} }); } }
Lab Assignment 3: Unit Converter App
App Description In this lab, you will develop a Unit Converter App for temperature that converts Fahrenheit to Celsius and vise versa. The App starts with the main activity shown in the video link as provided below https://watch.screencastify.com/v/JQ5sKfgovEWzDO3Y1Elf
and allows the user to enter numeric values and choose the conversion type through EditText Celsius = (Fahrenheit - 32) * 5 / 9; Fahrenheit = (Celsius * 9 / 5) + 32;
Design Requirements The App should meet the following design requirements: 1. Use Constraint Layout 2. Use TextViews for labels and result 3. Use EditTexts for selecting unit and to enter the value to be converted 5. Save all strings in strings.xml and colors in color.xml a. If both units are the same, the app should respond with an error message or Toast message b. If no value entered, the app should respond with an error message or Toast message c. if all white spaces are added, app should respond with error message or Toast message 6. Update results onClick in all cases Submission Instructions Instructions 1. Compress your folder and rename the file lab_activity2_yourname and add all the files (java files, XML files used in your project and a working demo video of your application 2.
Marking Rubric Presentation 10% - App design including, fonts, colors, sizes, etc. Basics functionality 55% - All the bare basic requirements of a unit converter must be satisfied and basic functionality is working perfectly. Usability 20% - Clear feedback on button clicks. - Hints for data entry. - Input validation. - Control the Precision of Numerical Results (1 digit) Creative Thinking 20% -Add the functionality of Change results on the change of value without clicking on convert button TOTAL 100%
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started